HTMLEditor会导致调用目标异常,尽管修改了VM选项并与其他JavaFX程序一起使用

HTMLEditor会导致调用目标异常,尽管修改了VM选项并与其他JavaFX程序一起使用,java,exception,javafx,Java,Exception,Javafx,我以前一起使用过JavaFX和IntelliJ,我通常能够让它工作。现在我正在尝试使用HTMLEditor,尽管为IntelliJ提供了指向我的JavaFX库目录的路径,并为“MyHTMLEditor”类的vm选项添加了我通常执行的相同指令,但我仍然不断收到调用目标异常 我已经在其他程序上成功地使用相同的设置运行了JavaFX,所以我觉得可能需要在vm选项中添加一些模块来让HTMLEditor工作,但我不知道是什么 如何阻止HTMLEditor对象生成错误 我使用的是OpenJFX12和Orac

我以前一起使用过JavaFX和IntelliJ,我通常能够让它工作。现在我正在尝试使用HTMLEditor,尽管为IntelliJ提供了指向我的JavaFX库目录的路径,并为“MyHTMLEditor”类的vm选项添加了我通常执行的相同指令,但我仍然不断收到调用目标异常

我已经在其他程序上成功地使用相同的设置运行了JavaFX,所以我觉得可能需要在vm选项中添加一些模块来让HTMLEditor工作,但我不知道是什么

如何阻止HTMLEditor对象生成错误

我使用的是OpenJFX12和Oracle Java 12

虚拟机选项说明:

public class MyHTMLEditor extends Application {

@Override
public void start(Stage stage) {

   stage.setTitle("My HTMLEditor");

   stage.setWidth(650650);
   stage.setHeight(300);

   final HTMLEditor htmlEditor = new HTMLEditor();
   htmlEditor.setPrefHeight(245);

   Scene scene = new Scene(htmlEditor);
   stage.setScene(scene);

   stage.show();
}

public static void main(String[] args) {
   launch(args);
}
}
Exception in Application start method
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 javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    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: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    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.IllegalAccessError: class javafx.scene.web.HTMLEditor (in unnamed module @0x1858dacf) cannot access class com.sun.javafx.scene.control.ControlHelper (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control to unnamed module @0x1858dacf
    at javafx.scene.web.HTMLEditor.<init>(HTMLEditor.java:50)
    at controllers.MyHTMLEditor.start(MyHTMLEditor.java:15)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
    ... 1 more
Exception running application controllers.MyHTMLEditor
--module path/home/myName/Java_Libraries/javafx-sdk-12.0.1/lib--add modules=javafx.controls,javafx.fxml

节目:

public class MyHTMLEditor extends Application {

@Override
public void start(Stage stage) {

   stage.setTitle("My HTMLEditor");

   stage.setWidth(650650);
   stage.setHeight(300);

   final HTMLEditor htmlEditor = new HTMLEditor();
   htmlEditor.setPrefHeight(245);

   Scene scene = new Scene(htmlEditor);
   stage.setScene(scene);

   stage.show();
}

public static void main(String[] args) {
   launch(args);
}
}
Exception in Application start method
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 javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    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: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    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.IllegalAccessError: class javafx.scene.web.HTMLEditor (in unnamed module @0x1858dacf) cannot access class com.sun.javafx.scene.control.ControlHelper (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control to unnamed module @0x1858dacf
    at javafx.scene.web.HTMLEditor.<init>(HTMLEditor.java:50)
    at controllers.MyHTMLEditor.start(MyHTMLEditor.java:15)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
    ... 1 more
Exception running application controllers.MyHTMLEditor
错误:

public class MyHTMLEditor extends Application {

@Override
public void start(Stage stage) {

   stage.setTitle("My HTMLEditor");

   stage.setWidth(650650);
   stage.setHeight(300);

   final HTMLEditor htmlEditor = new HTMLEditor();
   htmlEditor.setPrefHeight(245);

   Scene scene = new Scene(htmlEditor);
   stage.setScene(scene);

   stage.show();
}

public static void main(String[] args) {
   launch(args);
}
}
Exception in Application start method
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 javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    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: Exception in Application start method
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
    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.IllegalAccessError: class javafx.scene.web.HTMLEditor (in unnamed module @0x1858dacf) cannot access class com.sun.javafx.scene.control.ControlHelper (in module javafx.controls) because module javafx.controls does not export com.sun.javafx.scene.control to unnamed module @0x1858dacf
    at javafx.scene.web.HTMLEditor.<init>(HTMLEditor.java:50)
    at controllers.MyHTMLEditor.start(MyHTMLEditor.java:15)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:389)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
    ... 1 more
Exception running application controllers.MyHTMLEditor
应用程序启动方法中出现异常 java.lang.reflect.InvocationTargetException 位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 位于java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 位于java.base/java.lang.reflect.Method.invoke(Method.java:567) 位于javafx.graphics/com.sun.javafx.application.LaunchImpl.launchApplicationWithArgs(LaunchImpl.java:464) 位于javafx.graphics/com.sun.javafx.application.LaunchImpl.launchApplication(LaunchImpl.java:363) 位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 位于java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 位于java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 位于java.base/java.lang.reflect.Method.invoke(Method.java:567) 位于java.base/sun.launcher.launchelper$FXHelper.main(launchelper.java:1051) 原因:java.lang.RuntimeException:应用程序启动方法中的异常 位于javafx.graphics/com.sun.javafx.application.LaunchImpl.launchApplication1(LaunchImpl.java:900) 在javafx.graphics/com.sun.javafx.application.LaunchImpl.lambda$launchApplication$2(LaunchImpl.java:195) 位于java.base/java.lang.Thread.run(Thread.java:835) 原因:java.lang.IllegalAccessError:class javafx.scene.web.HTMLEditor(在未命名模块@0x1858dacf中)无法访问class com.sun.javafx.scene.control.ControlHelper(在模块javafx.controls中),因为模块javafx.controls没有将com.sun.javafx.scene.control导出到未命名模块@0x1858dacf 位于javafx.scene.web.HTMLEditor(HTMLEditor.java:50) 在controllers.MyHTMLEditor.start(MyHTMLEditor.java:15) 在javafx.graphics/com.sun.javafx.application.launchempl.lambda$launchApplication1$9(launchempl.java:846) 在javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455) 在javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428) 位于java.base/java.security.AccessController.doPrivileged(AccessController.java:389) 位于javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427) 位于javafx.graphics/com.sun.glass.ui.invokelateDispatcher$Future.run(invokelateDispatcher.java:96) 在javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.\u runLoop(本机方法) 在javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277) ... 还有一个 运行应用程序控制器时出现异常。MyHTMLEditor 我只需要在VM选项说明的末尾添加“、javafx.web”

逗号和“javafx.web”之间没有空格是很重要的

因此,VM选项说明变为:

--module path/home/myName/Java_Libraries/javafx-sdk-12.0.1/lib--add modules=javafx.controls、javafx.fxml、javafx.web

我只需要在VM选项说明的末尾添加“、javafx.web”

逗号和“javafx.web”之间没有空格是很重要的

因此,VM选项说明变为:


--module path/home/myName/Java_Libraries/javafx-sdk-12.0.1/lib--add modules=javafx.controls,javafx.fxml,javafx.web

如果你觉得有必要否决,请告诉我为什么,这样我才能改进这个问题。如果你觉得有必要否决,请告诉我为什么,这样我才能改进这个问题。