2

I have created a Java Application and have exported it to a .jar file. It runs perfectly fine displaying the required output and messages when i run it on my machine on NetBeans.

Whereas, my friend executed it on her computer but didn't work. I used Launch4j to convert it to .exe and still the application doesn't work as need.

I have used Jasypt library and imported all the .jar files to the project. whenever i run it. Launch4j throws these errors:

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

Can anyone tell me what's happening?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • You probably should create single jar (that will contain all needed jars), and then use `Launch4j` ... take a look here [Launch4J - how to attach dependent jars to generated exe](http://stackoverflow.com/questions/19917960/launch4j-how-to-attach-dependent-jars-to-generated-exe) – PKey Apr 20 '17 at 17:06
  • Knowing how you compiled it would be loads more useful. It sounds like your manifest may not have been pointing to the correct `Main-Class`. – Carter Brainerd Apr 20 '17 at 17:07
  • The `NoClassDefFoundError` means that despite whatever you did, that library is not on the run-time class-path of the application. I strongly suggest getting it working as an executable Jar before worrying about creating an app. using Launch4J, as that only has the information you are providing it to work on. Get that information (in the build) right to start with, and Launch4J will probably a) work, and b) be unnecessary. – Andrew Thompson Apr 20 '17 at 17:35
  • Thanks @Plirkee. I use the guide. I successfully did it. Thanks so much – Sumanth Saligram Apr 20 '17 at 17:49
  • @SumanthSaligram You're Welcome. I'am glad it worked for you. It seems, however, that you have accepted an answer - that was not your solution - could be misleading for future references... – PKey Apr 21 '17 at 06:00
  • @Plirkee Thanks for pointing that out. Didn't see it, my bad. Post your answer. Im gonna accept it as a solution – Sumanth Saligram Apr 22 '17 at 17:07

2 Answers2

0

I think about two things:

  • Has your friend Java on his computer? (Runtime library)
  • If your jar file works for your OS, try to use Launch4j on your friend's OS to have a .exe with your jar file.
0

You should create a single main jar file that will contain all needed jars (libraries) and then you can use Launch4j to generate your exe file.

Take a look here Launch4J - how to attach dependent jars to generated exe

Community
  • 1
  • 1
PKey
  • 3,715
  • 1
  • 14
  • 39