1

我在我的应用程序中使用 Synthetica Look and Feel,它在 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

我不知道问题到底出在哪里。这是我应用 Synthetica Blue Steel 外观和感觉的方式:

try 
    {
      UIManager.setLookAndFeel(new SyntheticaBlueSteelLookAndFeel());
      UIManager.put("Synthetica.rootPane.titlePane.title.center", true);
      UIManager.put("Synthetica.translucency4DisabledIcons.enabled", true); 

    } 
    catch (Exception e) {}
4

2 回答 2

0

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

尝试将 jar 导出为 Runnable jar 文件。
按照以下步骤将您的应用导出为可运行的 jar。
1) 从文件菜单中选择导出。
2) 选择Java->Runnable JAR 文件
3) 选择启动配置,即你的主类。
4)如果要将物质库文件打包到自己的jar中,则库处理的前两个选项和第三个选项(将所需的库复制到生成的jar旁边的子文件夹中)如果要将生成的jar文件和物质分开库。
5)按完成。

我希望这能解决你的问题。:)

于 2013-12-24T20:53:13.977 回答
0

请查看它找不到 sun/swing/plaf/synth/SynthUI 库的错误。在开发模式下,您将该 jar 文件包含在 eclipse 库中,但是当您创建 jar 文件时,您不包含 Synthui 主题 jar。将 Synthui jar 文件放在 jar、ext/ 文件夹中,它可以正常工作

于 2013-12-24T14:01:21.980 回答