我已经安装了 intellij,我正在尝试打开一个新的 javafx,但我无法运行它(即使是默认的基本版本,也应该只打开一个简单的窗口)我正在使用 jdk 11(我必须)所以我下载了javafx,就像这篇文章中所说的那样:
错误:缺少 JavaFX 运行时组件,需要使用 JDK 11 运行此应用程序
但我得到这个错误
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2018.2.5\lib\idea_rt.jar=59874:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\itzik\IdeaProjects\untitled3\out\production\untitled3;C:\Program Files\Java\javafx-sdk-11\lib\src.zip;C:\Program Files\Java\javafx-sdk-11\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.graphics.jar" sample.Main
Error: JavaFX runtime components are missing, and are required to run this application
Process finished with exit code 1
如果我尝试在解决方案中执行此行
然后在运行->编辑配置->虚拟机选项中,输入:--module-path="C:\Program Files\Java\javafx-sdk-11\lib" --add-modules=javafx.controls
错误更改为:
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" "--module-path=C:\Program Files\Java\javafx-sdk-11\lib"
--add-modules=javafx.controls "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA
2018.2.5\lib\idea_rt.jar=59984:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\itzik\IdeaProjects\untitled3\out\production\untitled3;C:\Program Files\Java\javafx-sdk-11\lib\src.zip;C:\Program Files\Java\javafx-sdk-11\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11\lib\javafx.graphics.jar" sample.Main 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:566) 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:566) 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:834) Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x555df7da) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x555df7da at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38) at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2056) at sample.Main.start(Main.java:13) 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(Native Method) 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.win.WinApplication._runLoop(Native Method) at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174) ... 1 more Exception running application sample.Main
Process finished with exit code 1
我试图在网上搜索超过 2 小时来解决这个问题,但没有任何效果 =\ 尝试在项目结构中将语言级别设置为 8\10\11,但仍然无法正常工作
带有hello world的常规java程序确实可以工作,只是java fx会出现问题......