Java: NoClassDefFoundError when run from terminal but not from netbeans
I see strange behavior when I try to run the jar file. I can start and execute my java application from netbeans without any problem. But when I tried to run the jar file from the terminal, I get an exception NoClassDefFoundError
in some Java classes.
StackTrace:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class java.nio.file.TempFileHelper
at java.nio.file.Files.createTempFile(Files.java:805)
at sun.font.FcFontConfiguration.writeFcInfo(FcFontConfiguration.java:391)
at sun.font.FcFontConfiguration.init(FcFontConfiguration.java:100)
at sun.font.FcFontConfiguration.<init>(FcFontConfiguration.java:75)
at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:747)
at sun.font.SunFontManager$2.run(SunFontManager.java:431)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.SunFontManager.<init>(SunFontManager.java:376)
at sun.awt.X11FontManager.<init>(X11FontManager.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorIm
By passing in the verbose java argument, I see the loaded java.nio.file.TempFileHelper
.
im running my application on Linux (Fedora 20)
Excerpt: [Loaded java.nio.file.TempFileHelper from /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64/jre/lib/rt.jar]
detailed log: http://pastebin.com/ekuQfkgG
What can I do?
EDIT: Running my application using the same java interpreter that was used to compile the applications:
/usr/java/jdk1.7.0_60/jre/bin/java -jar InstaladoruraClientes/Cliente.jar
source to share
I recommend installing oracle jdk following this guide .
To simplify each new version, after the break, create a soft link, for example:
ln -s jdk1.8.0_45 jdk
and replace in each case in the manual "jdk1.8.0_45" with "jdk". This way, every time you need to update a new version, you only need to download it and update the jdk link.
// of theourse replace jdk18.0_45 from the above example with this version
source to share