1

I had this working before, and I am 99% positive I have been following the same procedure I have used in the past of adding the lib to the project file structure, adding VM options in the Edit Configurations menu. For some reason I still cannot get JavaFX to work with my setup the way it did in the past. My old projects still run and were written with the same libraries and Java version. I have been banging my head on the wall with this issue all morning, I feel as though the solution may be sitting right in front of me. I have no clue what else to try from here, Reddit has been useless and everything I've searched has been the same.

I have tried running with both, when I took the VM options out the last time I finally got my errors in the editor to go away, but get the errors I had in the original post, this is why I didn't include them in the ZIP but included them in the post.

https://ufile.io/6iknpzqy

I have tried with these VM options and without:

--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml

Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195) at java.base/java.lang.Thread.run(Thread.java:832) Caused by: java.lang.IllegalAccessError: superclass access check failed: class com.sun.javafx.scene.control.ControlHelper (in unnamed module @0x34ce8af7) cannot access class com.sun.javafx.scene.layout.RegionHelper (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module @0x34ce8af7 at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at javafx.scene.control.Control.<clinit>(Control.java:86) at DoMath.start(DoMath.java:36) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) at java.base/java.security.AccessController.doPrivileged(AccessController.java:391) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run$$$capture(InvokeLaterDispatcher.java:96) at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277) ... 1 more Exception running application DoMath Disconnected from the target VM, address: '127.0.0.1:51735', transport: 'socket' Process finished with exit code 1 
10
  • 1
    Is this a modular project? How are you running it? Commented Jan 26, 2021 at 18:41
  • 1
    Please share the Minimal, Complete, and Verifiable example. Commented Jan 26, 2021 at 18:55
  • 1
    Where did you specify it? The project zip you linked doesn't have these options in the Run configuration. Commented Jan 26, 2021 at 19:06
  • 1
    Make sure the options were added to the VM Options. And not to the Program arguments. Please see this correct screenshot. Notice that command arguments field is empty and VM Options field is used. Your project is also using JDK 14, so you may need to add --add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED per the documentation. Commented Jan 26, 2021 at 19:28
  • 2
    That error can only mean that javafx.controls is not being resolved as a module, but the classes in that module can still be found on the class-path. You mention you used --add-modules javafx.controls,javafx.fxml but I would double check. Also, it may be easier to make your code modular and simply add the necessary requires directives. Commented Jan 26, 2021 at 20:05

1 Answer 1

1

Your project is using Java 14, even though you initially specified Java 11 in the question.

Per the documentation when using Java 14 the following VM Options are also needed:

--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED 

in addition to these options:

--module-path /home/(myUser)/Downloads/javafx-sdk-15.0.1/lib --add-modules=javafx.controls,javafx.fxml 

Double check all the options are specified in the VM Options field of the Run Configuration, not in the Program Arguments.

VM Options

Sign up to request clarification or add additional context in comments.

1 Comment

interesting .. wondering why the extra add-exports? can't remember any particular change in fx14 (vs. earlier modulized versions) - but then, I tend to keep my dev machine unchanged as long as possible <g>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.