Im trying to start application but got errors:
java.lang.ClassNotFoundException: com.sun.glass.ui.gtk.GtkPlatformFactory at
java.net.URLClassLoader.findClass(URLClassLoader.java:381) at
java.lang.ClassLoader.loadClass(ClassLoader.java:424) at
java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:264) at
com.sun.glass.ui.PlatformFactory.getPlatformFactory(PlatformFactory.java:42)
at com.sun.glass.ui.Application.run(Application.java:146) at
com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at
com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at
com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at
com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
at
com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.NullPointerException at
com.sun.glass.ui.Application.run(Application.java:146) at
com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:257)
at
com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
at
com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
at
com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
at
com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
And a message Failed to load Glass factory class
at the end of the stack trace.
I also tried to add javafx as a maven dependency and to add this jar to classpath. And I use IDEA for my project.
UPDATE :
My code is simple Hello JavaFX exmaple:
public class Application extends javafx.application.Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
}
UPDATE 1:
I used debug and found the excpetion throws inside ThreadPoolExecutor.java at line 1057. Also:
And yes! After executing this code fragment first exception appears in the project console.
You need to download and install the openjfx lib.
sudo apt install openjfx
should do the trick.
Ok, I figured it out.
Firstly my jdk was broken so I downloaded new one.
And also in IDEA don't forget to change project sdk in Modules section even if you changed your sdk in Project tab.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.