我是 Javafx 的新手,我刚刚下载了 JDK 12 并遵循了教程,它有效但对我不起作用,(我正在使用模块来要求 javafx.controls)这里是代码:在我的主类中:
我在 SOFlow 中尝试了很多解决方案但没有结果,我尝试了:1)将 public 关键字添加到我的类中 2)删除了主要方法仍然不起作用帮助?
package com.teachersdunet.hellojavafx;
import javafx.application.Application;
import javafx.stage.Stage;
public class HelloApp extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
}
}
这是执行后的错误:
Exception in Application constructor
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Unable to construct Application instance: class com.teachersdunet.hellojavafx.HelloApp
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:890)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.IllegalAccessException: class com.sun.javafx.application.LauncherImpl (in module javafx.graphics) cannot access class com.teachersdunet.hellojavafx.HelloApp (in module com.teachersdunet.hellojavafx) because module com.teachersdunet.hellojavafx does not export com.teachersdunet.hellojavafx to module javafx.graphics
... 1 more
牛魔王的故事
胡子哥哥
相关分类