简体   繁体   中英

Launch4j - Exception in thread “main” java.lang.NoClassDefFoundError: javax/mail/MessagingException

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:

在此输入图像描述

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM