JavaFX Exception in thread “main” java.lang.NoClassDefFoundError: javafx/application/Application

前端 未结 11 1301
半阙折子戏
半阙折子戏 2020-12-01 08:09

I\'m getting this error

Exception in thread \"main\" java.lang.NoClassDefFoundError: javafx/application/Ap
plication
        at java.lang.ClassLoader.defineC         


        
11条回答
  •  甜味超标
    2020-12-01 08:22

    I had the same problem and below steps helped me to solve it,

    Adding the vm arguments while running the application,

    --module-path  /home/user/Java-libraries/openjfx-11.0.2_linux-x64_bin-sdk/javafx-sdk-11.0.2/lib/ --add-modules javafx.controls,javafx.fxml
    

    Note:

    • The --module-path will contain the jars of Java fx
    • I used open-jdk 13

    Configure this in your eclipse (If you are using so) or you can just compile and run like,

    Compile

    javac --module-path /path/to/java-fx-libs/ --add-modules javafx.controls,javafx.fxml *.java
    

    Run

    java --module-path /path/to/java-fx-libs/ --add-modules javafx.controls,javafx.fxml MyMainClass
    

提交回复
热议问题