Reputation: 1571
I'm trying to add some libraries to my project. When i debugging the application everything works perfect but when I compile the project and run it, i get:
Exception in thread "main" java.lang.NoClassDefFoundError: de/javasoft/plaf/synt
hetica/SyntheticaSimple2DLookAndFeel
at pkg_main.FRM_Main.main(FRM_Main.java:56)
Caused by: java.lang.ClassNotFoundException: de.javasoft.plaf.synthetica.Synthet
icaSimple2DLookAndFeel
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)
... 1 more
Looks like the JVM can't get the library. I tried the same in NetBeans and works perfectly so i think it's Eclipse problem.
If anyone can help me please. Thanks in advance!
Upvotes: 0
Views: 4984
Reputation: 5094
You're compiling/exporting your code successfully, but when you run it you're missing libraries from your classpath.
The difference between netbeans and eclipse is most likely that by default, netbeans includes all libraries in the jar when you export and eclipse does not. If you intend to package everything in a single jar, make sure that when you export from eclipse that you select all of the libraries on the first export screen.
If you'd prefer to export only your code(like if you expect to switch versions of a library without rebuilding your jar), you can continue exporting only your code, but when you run it you have to specify the libraries in the classpath
java -cp "yourJar.jar;lib/*" my.package.MainClass
Upvotes: 1
Reputation: 144
Check your classpath in both eclipse as well as Netbeans you will see the differnce,
Upvotes: 0