I set up LWJGL 3 in Eclipse, and it's giving me this error when I try to run the test code from https://www.lwjgl.org/guide:
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.system.Library
at org.lwjgl.system.MemoryAccess.<clinit>(MemoryAccess.java:22)
at org.lwjgl.system.Pointer.<clinit>(Pointer.java:22)
at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:594)
at HelloWorld.run(HelloWorld.java:30)
at HelloWorld.main(HelloWorld.java:109)
I made sure that everything is set up correctly, and I just can't place my finger on the problem. What's wrong?
You're missing the native libraries.
As described in this link https://www.lwjgl.org/guide you'll have to setup java.library.path to the native library location.
I downloaded the library and copied the HelloWorld code in the above link in HelloWorld.java inside the directory where I extracted the library.
So the contents inside looks like below
/HelloWorld.java
/build.txt
/doc
/jar
/native
/src.zip
I compiled and ran the HelloWorld.java as below
Compilation (Path separator on linux would be : so there it would be -classpath jar/*:.)
javac -classpath jar/*;. HelloWorld.java
Run
java -classpath jar/*;. -Djava.library.path=native HelloWorld
And this works.
Edit*
I downloaded the library from https://www.lwjgl.org/download (Download Release.)
In eclipse you can add the native library to your path by simply including it on source path. Like below:
There's one more way using which native library can be added per Jar basis.
Expand lwjgl.jar in build path > select native path > click on edit > click workspace > select native directory.
See the images below