2

I tried many hints given but I couldnt fix this problem. I would really appriciate if someone could help me. The code seems really easy and its even from a book so I dont understand whats wrong. If u need more information pls write a comment. Thanks.

Code:

package sample;

import javafx.application.Application;
import javafx.scene.control.Label;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.*;

public class Main extends Application {

    @Override
    public void start(Stage stage){
        var label = new Label ("Willkommen zu unserem Fensterbasiertem
        Programm!");                 
        var scene = new Scene(new StackPane(label),500, 300);
        stage.setTitle("Fenster 1");
        stage.setScene(scene);
        stage.show();

    }


    public static void main(String[] args) {
        launch(args);
    }
}

Error:

Exception in Application start method

Stack Trace:

java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    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:64)
    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:1071)
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 @0x4c84bebb) 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 @0x4c84bebb
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:825)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:723)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:646)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:604)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at javafx.scene.control.Control.<clinit>(Control.java:86)
    at sample.Main.start(Main.java:13)
    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
Exception running application sample.Main

Process finished with exit code 1
zVepox
  • 21
  • 2
  • 1
    Don't paste images of text, paste text and format it. Here is how you [format code](https://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks) and here is how you [format pretty much everything](https://stackoverflow.com/help/formatting). This tool can fix your [spelling and grammar](https://www.grammarly.com/). – jewelsea Nov 28 '20 at 12:58
  • Sorry, we [can't accept images of code, data or errors](https://meta.stackoverflow.com/a/285557). Post those as *text*, so that we can try to reproduce the problem without having to re-type everything, and your question can be properly indexed or read by screen readers. – Martijn Pieters Nov 28 '20 at 15:10
  • I replaced the images with text now, pls let me know if i should edit anything else – zVepox Nov 28 '20 at 16:42
  • Thanks for replacing the images with text. I voted to re-open the question, but don't have sufficient privilege to re-open it on my own. The question is relevant and there is enough in the question that it should be re-opened, so hopefully with more votes it will be re-opened and answered. – jewelsea Nov 29 '20 at 09:37
  • Issue looks like it is to do with module export access privileges and can probably be fixed by adding command line options. See this related question [JavaFX module does not export to unnamed module](https://stackoverflow.com/questions/59625091/javafx-module-does-not-export-to-unnamed-module), which is gradle specific, but might give you a hint of the command line options needed. See also the info on running hello world for JavaFX at [openjfx.io](https://openjfx.io/openjfx-docs/#install-javafx). – jewelsea Nov 29 '20 at 09:43

0 Answers0