1

I used launch4j (http://launch4j.sourceforge.net/) software to create an executable of my application created in java netbeans.

I did everything as I saw in a tutorial, just that when I run the exectutavel it creates in my application, it gives this error:

enter image description here

The message shown below is:

 Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
 Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
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)
    ... 6 more

Does anyone can help me solve this problem please.

I've been searching but I can not solve. I apologize for this question but am new to java.

Thank you all.

Greetings

strange_098
  • 1,261
  • 6
  • 24
  • 44

2 Answers2

2

In your launch4j configuration file add the jars like this

<classPath mainClass="your.main.class">
    <cp>path/to/javamail.jar</cp>
    <cp>path/to/folder/*.jar</cp> // you can also add all the jars in a folder like this
</classPath>

It will automatically bundle them.

Hope this helps

EDIT

Just went through netbeans integration with launch4j and it seems there is no way to write your on config xml file instead it prompts you in launch4J GUI for dependencies. I searched and found this Stackoverflow Post. This is what you want. Good Luck.

Community
  • 1
  • 1
Sanjeev
  • 9,876
  • 2
  • 22
  • 33
1

Add Java mail jar to classpath.

Download it from here http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.7-oth-JPR

Jay
  • 9,189
  • 12
  • 56
  • 96
  • Thanks for reply. how can I Add Java mail jar to classpath? Sorry for question, but i'm new at programming java... – strange_098 May 07 '14 at 11:21
  • One way is, from you Eclipse project right click > Properties > java Build path. And in Libraries tab click Add external jars and add this jar from your hard disk location. – Jay May 07 '14 at 11:23
  • There will some thing equivalent. – Jay May 07 '14 at 11:26