Skip to content
Advertisement

LibGDX project isn’t launching, it says Could not initialize class org.lwjgl.Sys

Whenever I try to launch a LibGDX project, the problem shown below keeps appearing:

Starting Gradle Daemon...
Gradle Daemon started in 2 s 577 ms
> Task :core:compileJava UP-TO-DATE
> Task :core:processResources NO-SOURCE
> Task :core:classes UP-TO-DATE
> Task :core:jar UP-TO-DATE
> Task :desktop:compileJava UP-TO-DATE
> Task :desktop:processResources UP-TO-DATE
> Task :desktop:classes UP-TO-DATE

> Task :desktop:DesktopLauncher.main()
[LwjglApplication] Couldn't initialize audio, disabling audio
java.lang.UnsatisfiedLinkError: /tmp/libgdxalice/dd5c1a65/liblwjgl64.so: /usr/lib/jvm/jdk-17/lib/libjawt.so: version `SUNWprivate_1.1' not found (required by /tmp/libgdxalice/dd5c1a65/liblwjgl64.so)
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
    at java.base/java.lang.Runtime.load0(Runtime.java:755)
    at java.base/java.lang.System.load(System.java:1953)
    at org.lwjgl.Sys$1.run(Sys.java:70)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
    at org.lwjgl.Sys.loadLibrary(Sys.java:87)
    at org.lwjgl.Sys.<clinit>(Sys.java:117)
    at org.lwjgl.openal.AL.<clinit>(AL.java:59)
    at com.badlogic.gdx.backends.lwjgl.audio.OpenALLwjglAudio.<init>(OpenALLwjglAudio.java:72)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.createAudio(LwjglApplication.java:282)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:90)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:71)
    at com.kuuject.atherwund.desktop.DesktopLauncher.main(DesktopLauncher.java:10)

BUILD SUCCESSFUL in 13s
5 actionable tasks: 1 executed, 4 up-to-date
Exception in thread "LWJGL Application" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.Sys
    at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
    at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setVSync(LwjglGraphics.java:643)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:125)
9:18:30 AM: Execution finished ':desktop:DesktopLauncher.main()'.

I can’t for the life of me figure out the solution. At first, I tried reinstalling my JDK, but that wasn’t the issue at all. It wasn’t an issue before I switched to PopOS. Any help?

Advertisement

Answer

I found out the issue. You need to change the LWJGL api in build.gradle, dependencies to LWJGL3.

api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"

to

api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"

In DesktopLauncher.java, change these

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;

and

LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new MyGdxGame(), config);

to

import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;

and

Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
new Lwjgl3Application(new MyGdxGame(), config);
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement