nll*_*dfx 5 java javafx javafx-8
我试图启动应用程序但出现错误:
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
Run Code Online (Sandbox Code Playgroud)
以及Failed to load Glass factory class堆栈跟踪末尾的消息。
我还尝试将 javafx 添加为 maven 依赖项并将此 jar 添加到类路径。我在我的项目中使用 IDEA。
更新:
我的代码很简单 Hello JavaFX 示例:
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();
}
}
Run Code Online (Sandbox Code Playgroud)
更新1:
我使用 debug 并在 ThreadPoolExecutor.java 中的第 1057 行发现了 excpetion throws。另外:
是的!执行此代码片段后,项目控制台中出现第一个异常。
| 归档时间: |
|
| 查看次数: |
2757 次 |
| 最近记录: |