简体   繁体   中英

Convert .jar to .exe using launch4j

I have java project I convert it to .jar file using netbeans Clean & Build, I used cmd to run the .jar file it successfully run without errors, then I want to convert it to .exe file using launch4j but the problem is I have this error:

Executing: C:\Users\LaLa\Desktop\el.exe
Exception in thread "main" java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.privateGetMethodRecursive(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.toedter.calendar.JDateChooser
    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)
    ... 7 more

What could be the possible error I made? or I shouldn't made to avoid it?

(I'm totally new to java programming, I'd ask you please to write solution in details)

Looks like the required libraries are not in the classpath.

Consider using maven-assembly-plugin , it will produce a single jar-with-dependencies file which can be converted to the .exe .

See also How can I create an executable JAR with dependencies using Maven?

I saved my .exe file in dist folder that contains my .jar file & lib folder. It worked as I wanted. Thanks to All!

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