java如何解决“图形设备初始化失败:d3d、sw”问题
在启动使用JavaFX11+的应用程序时,我遇到了以下问题RuntimeException
:
Graphics Device initialization failed for : d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:243)
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
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: Error initializing QuantumRenderer: no suitable pipeline found
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
at java.base/java.lang.Thread.run(Thread.java:835)
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: No toolkit found
at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
... 5 more
# 1 楼答案
对我有效的解决方案是将JavaFXSDK的
\bin
目录添加到java.library.path
。这与将文件从bin文件夹复制到JAVA_HOME
的路径具有相同的效果,但它保持了更改项目的特定性File -> Project Properties -> Run
# 2 楼答案
下载JavaFX11+后,提取文件,提取文件后,切换到IntelliJ IDEA。然后按照IntelliJ IDEA中的以下步骤操作
现在,将鼠标指针移动到“+”下,然后右键单击名为“javafx12”的库,此时会打开一个带有不同选项的小窗口,但在“添加到模块”上按鼠标指针之后,将鼠标指针移动到“src”文件夹并用鼠标右键单击。现在打开一个带有各种选项的宽窗口,但您选择了“新建”选项,现在打开了一个带有许多不同选项的宽窗口,但您再次选择了“module info.java”,现在您复制以下文本:
这就解决了问题
# 3 楼答案
使用下面的链接下载JavaFX Windows SDK
https://gluonhq.com/products/javafx/
并在运行FX应用程序时在VM参数中使用以下选项
注意:不要更改已下载文件夹中的任何内容:按原样使用。DLL文件很重要;如果DLL文件丢失,则会弹出上述错误
# 4 楼答案
您不必在模块信息中包含所有内容,只需包含您使用的部分。最低限度似乎是基础、控件和图形。(我的代码使用这些和fxml。)例如,如果您不使用swing或media,请使用javafx。swing和javafx。介质可以省略。渲染工具包(未找到的部分)位于Windows特定的二进制文件中。它位于javafxsdk/bin目录中。该目录必须是java的一部分。图书馆路径如果您使用的是模块,javafxsdk/lib可能是模块路径的一部分。(当然,特定版本是JavaFXSDK目录名的一部分。)
# 5 楼答案
我也面临同样的问题。原来我下载的是aarch64版本,而不是x64。 https://gluonhq.com/products/javafx/
# 6 楼答案
我强烈建议使用maven创建JavaFX程序。该方法在关于JavaFX的Intellij研讨会上进行了说明link 然而这个问题有一个简单的解决办法。您必须提取JavaFXSDK的所有内容;然后添加库,而不删除或更改其他子文件夹。如果只是复制lib子文件夹,它将不会寻址bin子文件夹中的文件夹