Java-无法应用Java外观

Java-无法应用Java外观,java,swing,jar,look-and-feel,synthetica,Java,Swing,Jar,Look And Feel,Synthetica,我在我的应用程序中使用了外观,它在Eclipse上运行良好。但是当我导出Jar文件并执行它时,我得到了以下错误: Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI at de.javasoft.plaf.synthetica.SyntheticaDefaultLookup.getDefault(SyntheticaDefaultLookup.jav

我在我的应用程序中使用了外观,它在Eclipse上运行良好。但是当我导出Jar文件并执行它时,我得到了以下错误:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun/swing/plaf/synth/SynthUI
at de.javasoft.plaf.synthetica.SyntheticaDefaultLookup.getDefault(SyntheticaDefaultLookup.java:105)
at sun.swing.DefaultLookup.get(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.getInputMap(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installKeyboardActions(Unknown Source)
at javax.swing.plaf.basic.BasicButtonUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.AbstractButton.setUI(Unknown Source)
at javax.swing.JButton.updateUI(Unknown Source)
at javax.swing.AbstractButton.init(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at javax.swing.JButton.<init>(Unknown Source)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel.installCompatibilityDefaults(SyntheticaLookAndFeel.java:925)
at de.javasoft.plaf.synthetica.SyntheticaLookAndFeel$4.propertyChange(SyntheticaLookAndFeel.java:582)
at java.beans.PropertyChangeSupport.fire(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at javax.swing.UIManager.setLookAndFeel(Unknown Source)
at com.evaluator.MainWindow.<init>(MainWindow.java:85)
at com.evaluator.Main$1.run(Main.java:15)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
   Caused by: java.lang.ClassNotFoundException: sun.swing.plaf.synth.SynthUI
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 35 more

请查看错误,因为它找不到sun/swing/plaf/synth/SynthUI
图书馆在开发模式中,您需要在eclipse库中包含该jar文件,但当您创建jar文件时,就不需要包含Synthui主题jar。将synthuijar文件放在jar、ext/文件夹中,它工作正常

我认为导出jar文件的方式不正确

尝试将jar导出为可运行的jar文件。 按照以下步骤将应用程序导出为可运行jar。 1从文件菜单中选择导出。 2选择Java->Runnable JAR文件 3选择启动配置,即主类。 4如果要将substance library文件打包到自己的jar中,则前两种库处理选项;如果要将生成的jar文件和substance库分开,则第三种选项将required library复制到生成的jar旁边的子文件夹中。 5压光


我希望这能解决你的问题

尝试将该jar文件放在jar的ext文件夹中,或将Synthui文件解压缩到您的项目文件夹中。我解压缩了Synthetica L&F的jar文件,应用程序已执行,但L&F未应用!你可以在这里查看我的代码,我已经应用了这个主题,在First.java文件中编写的代码,我想你只有一个Jar文件被提取出来。我对两个Jar文件做了同样的事情,正如我所说,我的应用程序随后被执行,但主题没有按预期应用。请提供您的Jar文件和代码,以便我可以查看它,并让您知道您面临的问题。更改catch Exception e{..形式的代码以捕获异常e{e.printStackTrace;//非常有用!。synthetica每周有一次,搜索用Java7编译的过时版本。这不是问题,我验证了。我不是直接从Eclipse导出,我使用的是用Ant编译的Xml文件。
try 
    {
      UIManager.setLookAndFeel(new SyntheticaBlueSteelLookAndFeel());
      UIManager.put("Synthetica.rootPane.titlePane.title.center", true);
      UIManager.put("Synthetica.translucency4DisabledIcons.enabled", true); 

    } 
    catch (Exception e) {}