应用程序(.jar)错误 - NoClassDefFoundError

时间:2017-04-20 16:54:58

标签: java swing noclassdeffounderror executable-jar

我创建了一个Java应用程序并将其导出到.jar文件中。 当我在NetBeans上的计算机上运行它时,它可以完美地显示所需的输出和消息。

然而,我的朋友在她的电脑上执行了它,但没有工作。我使用Launch4j将其转换为.exe,但应用程序仍然无法正常工作。

我使用了Jasypt库并将所有.jar文件导入到项目中。 每当我运行它。 Launch4j抛出这些错误:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jasypt/util/text/BasicTextEncryptor
at encryption.Encryption.encryption(Encryption.java:44)
at encryption.Encryption.jButton1ActionPerformed(Encryption.java:174)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at 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$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.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: org.jasypt.util.text.BasicTextEncryptor
    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)
    ... 39 more

有谁能告诉我发生了什么?

2 个答案:

答案 0 :(得分:0)

我想到两件事:

  • 你的朋友Java在他的电脑上吗? (运行时库)
  • 如果您的jar文件适用于您的操作系统,请尝试在您朋友的操作系统上使用Launch4j,以便在您的jar文件中使用.exe。

答案 1 :(得分:0)

您应创建一个包含所有必需jar(库)的主jars文件,然后您可以使用Launch4j生成exe文件。

看看Launch4J - how to attach dependent jars to generated exe