Java 15 and JavaFX

I’m have a simple JavaFX 15 app (example for a bachelor course) that I’m trying to run in the VNC image (in todolist-example folder in this branch: https://gitlab.stud.idi.ntnu.no/tdt4100/v2021/students/-/tree/todolist-example). I can install Java 14, configure the pom to use Java 14 and run it with Java 14. However, if I switch to Java 15 (install, configure and run) I get the following exception:
java.lang.NoClassDefFoundError: com.sun.glass.ui.Pixels
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:383)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:1787)
at java.base/java.lang.System.load(System.java:581)
at javafx.graphics/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)

Any suggestions?

Hi @hallvard!

I think not all SDKMAN Java versions have Java FX support. Maybe the Java version you’re trying to use doesn’t?

Hint: You can see all available versions by running sdk list java – then, a clue I typically use to indentify Java FX support is checking whether the version/identifier has the letter fx in it.

Maybe you could try using Java 15.0.1.fx-zulu instead of 15.0.1.j9-adpt?

Java and JavaFX are separate, I’m pulling JavaFX from maven. JavaFX N is supposed to work with Java N SDKs and lower. But you’re right, I can try some other Java distribution. Could it be due to gtk3 support in gitpod’s VNC image?

Aha, thanks, I didn’t know that.

Hope this works! :crossed_fingers:

I don’t quite see how GTK3 support in Gitpod’s VNC image could be related to the exception java.lang.NoClassDefFoundError: com.sun.glass.ui.Pixels, but since I don’t fully understand this NativeLibLoader mechanism, it could be that something is missing in the Docker image that is causing this error.

If that’s the case, I’m happy to help fix Gitpod’s VNC image by adding what was missing, or to help write a custom Dockerfile that extends Gitpod’s VNC image.

For reference, this is the source Dockerfile for Gitpod’s official VNC image:

Additionally, I know of one case where a project required additional graphics libraries (https://github.com/servo/servo, the Rust-based browser engine), which was achieved like so:

Furthermore, Servo also needed to slightly tweak Gitpod’s virtual desktop environment (Xvfb) in order to enable further graphics extensions. It did this like so:

Hope this helps!