如何解决“图形设备初始化失败:d3d,sw”问题

6 java javafx

RuntimeException在启动使用 JavaFX 11+ 的应用程序时,我遇到了以下问题:

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
Run Code Online (Sandbox Code Playgroud)

小智 6

使用以下链接下载 JavaFX Windows SDK

https://gluonhq.com/products/javafx/

并在运行 FX 应用程序时在 VM 参数中使用以下选项

-p $ModuleFileDir$/lib/javafx-sdk-11.0.2/lib --add-modules javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.web --add-opens=javafx.graphics/javafx.scene=ALL-UNNAMED --add-exports javafx.base/com.sun.javafx.event=ALL-UNNAMED
Run Code Online (Sandbox Code Playgroud)

注意:不要更改下载文件夹中的任何内容:按原样使用。DLL 文件很重要;如果缺少 DLL 文件,则会弹出上述错误。

  • 你的笔记是关键。不过,除了“--add-modules”之外,我没有使用任何其他东西。没有打开或导出。 (2认同)

小智 6

我遇到了同样的问题。原来我下载的是aarch64版本而不是x64。 https://gluonhq.com/products/javafx/

  • 我遇到了同样的问题,我错误地为我的 Windows 10 下载了 x86 存档而不是 x64。所以现在,它可以正常工作 (4认同)

小智 4

下载JavaFX 11+后,解压文件,解压后切换到IntelliJ IDEA。然后在 IntelliJ IDEA 中按照以下步骤操作。

  1. 文件
  2. 项目结构
  3. 全球图书馆
  4. 按“+”号,然后按 Java
  5. 转到您刚刚下载的 JavaFX 11+ 文件夹。进入文件夹,现在进入“lib”,选择文件夹中除“src.zip”之外的所有文件,然后按右下角的“确定”并将其另存为“javafx12”。
  6. 现在,您将鼠标指针移动到“+”下方,然后右键单击您命名为“javafx12”的库,现在会打开一个小窗口,其中包含不同的选项,但在执行此操作后,您将鼠标指针按在“添加到模块”上将鼠标指针移动到“src”文件夹并右键单击。现在打开一个带有各种选项的宽窗口,但您选择“新建”选项,现在打开了一个带有许多不同选项的宽窗口,但您再次选择“module-info.java”,现在复制以下文本:

    module YOUR-PROJECT-NAME {
    
        requires javafx.graphics;
        requires javafx.controls;
        requires javafx.media;
        requires javafx.base;
        requires javafx.web;
        requires javafx.swing;
        requires javafx.fxml;
    
        opens application;
    }
    
    Run Code Online (Sandbox Code Playgroud)

这样就解决了问题。