I am stuck at a very basic problem. I have created a simple hello world program using JavaFX which works fine on JDK 1.8. But when I switch to JDK-11 it throws following exception:
Error: Could not find or load main class application.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
Following is the code I wrote in eclipse.
package application;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
public class Main extends Application {
private Scene theScene;
@Override
public void start(Stage primaryStage) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("MyScene.fxml"));
Parent mainPane = loader.load();
theScene = new Scene(mainPane);
primaryStage.setScene(theScene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public void setTheScene(Scene theScene) {
this.theScene = theScene;
}
public static void main(String[] args) {
launch(args);
}
}