简体   繁体   中英

LWJGL project java.lang.NoClassDefFoundError

I'm working on a project using LWJGL and I can't seem to get my jar to run. It runs fine inside my IDE (netbeans), but the jar itself gives me the error.

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.opengl.Display

I've tried a lot of things to fix this error. I think it has something to do with the LWJGL natives not being correctly linked.

I've linked the natives in netbeans by putting this in the VM options.

-Djava.library.path="C:\Users\Lemonzap\Desktop\Projects\Game Programming\LWJGL -3\native\windows\x64"

The path is the path to where my 64 bit windows LWJGL natives are kept.

I've also tried adding this line to the beggining of main.

System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath());

I have a feeling that I need to change this line a bit though since there isn't a natives folder in my lib folder. I've spent a few days researching this issue and trying out other people's solutions with no luck. I would greatly appreciate some help with this problem.

Your natives need to be inside your jar. I had a lot of issues with this when I tried to deploy my LWJGL project.

I used Jarsplice to do it. It takes the IDE-built jar, adds the libraries and natives, and exports to a .jar , .exe , .app , or .sh .

On my Linux system, I had this error because the system library libXxf86vm.so.1 was missing. This means that a missing external library is also able to produce this error. On your windows, you probably need an extra dll.

These command solved in for me (on Ubuntu trusty):

sudo apt-get install libxxf86vm1 fglrx

Btw: it's also possible that java/jni/lwjgl have problems with pathnames containing spaces...

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