Професионална програма
Loading...
stoian_delev avatar stoian_delev 4 Точки

Грешка при компилиране

При опит за run на този код изписва тази грешка.

Моля за съдействие?

scr:

 

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
    }


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

 

 

/Users/stoiandelev/Library/Java/JavaVirtualMachines/openjdk-15/Contents/Home/bin/java --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED -Djava.library.path=/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib -javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=59103:/Applications/IntelliJ IDEA CE.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/stoiandelev/IdeaProjects/SceneBulder1/out/production/SceneBulder1:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/src.zip:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx-swt.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.web.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.base.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.fxml.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.media.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.swing.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.controls.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.graphics.jar -p /Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.base.jar:/Users/stoiandelev/Desktop/javafx-sdk-11.0.2/lib/javafx.graphics.jar sample.Main
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: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: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x4880bb79) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x4880bb79
    at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
    at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056)
    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)
Exception running application sample.Main

Process finished with exit code 1
 

 

 

 

 

Тагове:
0
Programming Basics with Java
stoian_delev avatar stoian_delev 4 Точки

Ако и на други им излиза следвайте тези инструкция и се оправят нещата:

https://openjfx.io/openjfx-docs/

0