Search code examples
javaintellij-idealwjgl

Java LWJGL (linux): Could not initialize class org.lwjgl.system.MemoryAccess


I just added lwjgl 3.1 to a project in Intellij IDEA. To verify everything was done correctly I tried to run the guide code in the webpage (https://www.lwjgl.org/guide), but when compiling the following error came out:

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

After a google search I found out that the possible error is in the configuration of the native libraries, which I have added when configuring the library in the project.

When LWJGL was downloaded from the webpage, I got a a zip file with all the jar files of the modules (classes, docs, natives and sources), what I did was to separate them accordingly and then add them as a single library in the global libraries section of the IDE. Global Libraries

After this, the library appears as a module of the project.

Still, the program won't compile. Is there anything else I should configure?


Solution

  • You claim that this is a compile-time error, however, after looking through the documentation, I have found out that this is a runtime error, where you successfully compile, but the JVM is unable to find the class at runtime. To solve this, I would suggest merging your .jar output and the lwjgl jar using jarsplice to see if that fixes it. If it fixes it, the problem is with intelliJ not correctly adding your libraries to your jar.