Trouble debugging Java FX 21 app
Answered
First, let me say, I am a beginner with java and have inherited an app. We wanted to update the app from Java 17 to Java 21. The app will run on Windows and Linux, but I am running IntelliJ on Windows. Also, the app uses JavaFX. The good news, we got it updated and it builds on our build server using Maven and the JAR works. However, I cannot debug it in IntelliJ. When I try to debug it, I get this exception:
java.lang.ClassNotFoundException: com.sun.glass.ui.win.WinPlatformFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:421)
at java.base/java.lang.Class.forName(Class.java:412)
at javafx.graphics@21.0.6/com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
at javafx.graphics@21.0.6/com.sun.glass.ui.Application.run(Application.java:146)
at javafx.graphics@21.0.6/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:290)
at javafx.graphics@21.0.6/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:292)
at javafx.graphics@21.0.6/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:162)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:651)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1149)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:115)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1149)
Caused by: java.lang.NullPointerException: Cannot invoke "com.sun.glass.ui.PlatformFactory.createApplication()" because the return value of "com.sun.glass.ui.PlatformFactory.getPlatformFactory()" is null
at javafx.graphics@21.0.6/com.sun.glass.ui.Application.run(Application.java:146)
at javafx.graphics@21.0.6/com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:290)
at javafx.graphics@21.0.6/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:292)
at javafx.graphics@21.0.6/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:162)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:651)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics@21.0.6/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 2 moreGoogling “getPlatformFactory is null” returned no helpful information. The debug configuration has these VM Options:
--module-path="C:/Temp/javafx-sdk-21.0.6/lib" --add-modules="javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing" --add-reads javafx.graphics=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.application=ALL-UNNAMED --add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED --add-reads javafx.base=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.logging=ALL-UNNAMED --add-opens javafx.base/com.sun.javafx.logging=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.embed=ALL-UNNAMEDI am posting this here because the Maven produced Jar works - even if built from IntelliJ. I just can't debug with IntelliJ.
Any help would be greatly appreciated.
Thanks
Please sign in to leave a comment.
no one has any ideas?
I ended up deleting module-info.java and debugging started working. Obviously, I won't check that change into source control, but at least I can debug again. hope this helps someone.
Hi Steve,
I've tried to set up a Gradle/JavaFX 21 project but failed to reproduce it, debug with the Gradle's run task. Could you please provide a minimal sample project so I can reproduce the issue without including your sensitive code? Thank you! Please upload it to https://uploads.jetbrains.com/ and paste the upload id here. The uploaded file is only visible to JetBrains employees.
build.gradle
mofule-info.java