0

Please help me. I would appreciate anyone who answer.

This is the error I see:

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 @0xb49eb09) 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 @0xb49eb09
    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 com.Thomas.Main.start(Main.java:23)
    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(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    ... 1 more

Please help me.

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
x---x
  • 1
  • 1
  • 1
    Can't help you without seeing any code. Please remember that we need something we can reproduce, not just a couple of lines! – AlgoRythm Apr 27 '20 at 06:56
  • Please paste your entire code into the question and format it with the "{}" tool. – NomadMaker Apr 27 '20 at 07:00
  • You probably use Java 11+ and use openJFX 11+ . It is a Modular Library, you need to tell the "Programm" wich modules you like to include. You can do this via "module-info.java" or gradle. This is just a guess since there is `because module javafx.graphics does not export com.sun.javafx.scene.layout to unnamed module` error – Luxusproblem Apr 27 '20 at 07:01

1 Answers1

0

How are you running your application?

With Java Platform Module System

The error indicates you are running your application on the Modulepath, but are not correctly setting your (JPMS) module settings.

One clue here is that it says "com.sun.javafx.scene.control.ControlHelper (in unnamed module @0xb49eb09)". If you run it correctly, by putting every JAR on the Modulepath, that package shouldn't be in the unnamed module but in an Automatic Module (with name: javafx.controls).

So first step is to add all your JavaFX jars to the Modulepath. Next is to create a module-info.java file to make your own code modular. I have an example project here: https://github.com/TomCools/jpms-hexagonal-architecture/blob/master/app-desktop-javafx/src/main/java/module-info.java

This does require some knowledge of how JPMS works. Else the alternative option below might be better if you are in a hurry.

Without Java Platform Module System

Alternatively. You can bypass all the Java Module stuff by just putting everything (JAR/Class files) onto the Classpath instead. Doing this won't activate the module system and you shouldn't have that error anymore.

Community
  • 1
  • 1
Tom Cools
  • 1,098
  • 8
  • 23