0

我试图从 jar 文件中制作一个 exe。它做得很好,当我运行它时,它会给出一个像这样的记事本错误文件, (当我在 netbeans(shift+F6) 上运行它时它可以正常工作)

线程“AWT-EventQueue-0”中的异常 java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout at Experiments.mp3Player.initComponents(mp3Player.java:115) at Experiments.mp3Player.(mp3Player.java:26)在 Experiments.Main$1.run(Main.java:17) 在 java.awt.event.InvocationEvent.dispatch(Unknown Source) 在 java.awt.EventQueue.dispatchEventImpl(Unknown Source) 在 java.awt.EventQueue.access$500( 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 (未知来源)在 java.awt.EventDispatchThread.pumpOneEventForFilters(未知来源)在 java.awt 的 java.awt.EventQueue.dispatchEvent(未知来源)。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) 原因:java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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) ... 17 更多*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) 原因:java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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) ... 17 更多*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) 原因:java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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) ... 17 更多*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) 原因:java.lang。 ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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)。 .. 还有 17 个*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) 原因:java.lang。 ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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)。 .. 还有 17 个*pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 原因:java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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) ... 17 更多*pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) 原因:java.lang.ClassNotFoundException: org.netbeans.lib.awtextra.AbsoluteLayout 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) ... 17 更多*AbsoluteLayout 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) ... 17 更多*AbsoluteLayout 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) ... 17 更多*loadClass(Unknown Source) ... 17 更多*loadClass(Unknown Source) ... 17 更多*

4

2 回答 2

1

在 exe4j 中,您需要包含应用程序使用的所有依赖项 Jar。当您使用 Netbeans 表单编辑器和它的“默认”布局管理器时,您需要包含它的库 Jar,它不是默认 JRE 的一部分。

exe4j

浏览到您的项目目录并查看该dist\lib目录。您将需要包括其中列出的所有 jar 文件

于 2015-04-08T02:53:47.090 回答
0

这是因为您已针对 netbeans jar 编译它,但它们未包含在类路径中。您必须以一种或另一种方式将它们放在课程路径上。您可以在 jar 导出中包含这些库,它们应该会自动显示,或者您可以在启动 exe 时硬编码它们在类路径中的位置(编辑它的启动脚本)。

我推荐第一个选项,因为它使它在您从一个系统到另一个系统时更加便携。

于 2015-04-08T02:47:50.013 回答