迁移到 JDK 11 + JavaFX 11 给出 RuntimeException [英] Migration to JDK 11 + JavaFX 11 giving RuntimeException
问题描述
我有一个 Java 8 + JavaFX 应用程序,我想迁移到 Java 11.基本目标是为网络上的用户提供一个 .jar,以便他们可以使用这个小应用程序.我使用 JavaFX 作为接口,使用 sqlite-jdbc 来生成数据库.
I've got an application on Java 8 + JavaFX that I want to migrate to Java 11. The basis aim is to give a .jar to users on a network and so they can use this little application. I'm using JavaFX for the interface and sqlite-jdbc to generate a database.
我有我的 module-info.java,编译似乎没问题:没有错误.但是,如果我运行该应用程序,则会出现此错误:
I've my module-info.java, the compilation seems to be OK: no errors. But if I run the application, I've got this error:
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:222)
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:566)
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:834)
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:566)
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
我的模块信息.java
My module-info.java
module AutoGeneratorOpenData {
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires sqlite.jdbc;
requires java.sql;
requires java.desktop;
exports autogeneratoropendata;
}
我在 Windows 10 x64 位和 JavaFX Windows SDK(最新版本 11)上使用 Netbeans 9.我没有使用 Maven(但也许我必须使用?).
I'm using Netbeans 9 on Windows 10 x64bits and JavaFX Windows SDK (last version 11). I'm not using Maven (but maybe I must?).
有没有办法解决这个问题?
Any idea to fix that?
推荐答案
因此,缺少一些库.
在 Windows 上,javafx-sdk-11/bin 中缺失的 DLL 至少是prism_d3d.dll、prism_sw.dll、javafx_font.dll、glass.dll;你可以把所有的放到jdk目录
C:Program FilesJavajdk[...]in
(这不是最好的解决方案),或者进入自定义 JRE 的 jlink 目录,位于内.[...]jlinkin
On Windows, the missing DLL from javafx-sdk-11/bin are at least prism_d3d.dll, prism_sw.dll, javafx_font.dll, glass.dll; you can put all into the jdk directory
C:Program FilesJavajdk[...]in
(It's not the best solution), or into the jlink directory for a custom JRE, inside.[...]jlinkin
在 Linux 上,javafx-sdk-11/lib 中缺少的 .so 至少是 libprism_es2.os、libprism_sw.so、libglass.so、libglassgtk3.so(和 libglassgtk2.so).所以对于旧配置可能也是如此)、libjavafx_font.so、libjavafx_font_freetype.so、libjavafx_font_pango.so;例如,您可以将所有内容放入 /usr/lib/jvm/java-11[...]/lib
(这不是最佳解决方案),或进入自定义 JRE 的 jlink 目录,在 [...]/jlink/lib
内.
On Linux, the missing .so from javafx-sdk-11/lib are at least libprism_es2.os, libprism_sw.so, libglass.so, libglassgtk3.so (and libglassgtk2.so probably too for old configuration), libjavafx_font.so, libjavafx_font_freetype.so, libjavafx_font_pango.so; you can put all into the /usr/lib/jvm/java-11[...]/lib
for example (It's not the best solution), or into the jlink directory for a custom JRE, inside [...]/jlink/lib
.
在 Mac 上,jav javafx-sdk-11/lib 中丢失的 .dylib 必须是(我想!)libprism_es2.dylib、libprism_sw.dylib、libglass.dylib、libjavafx_font.dylib [确认].
On Mac, the missing .dylib from jav javafx-sdk-11/lib must be (I suppose!) libprism_es2.dylib, libprism_sw.dylib, libglass.dylib, libjavafx_font.dylib [To confirm].
要使用 jlink,您应该使用 jmods - 无需使用库文件.
To use the jlink, you should use the jmods - no need to use the librairy files.
而且我的 module-info.java 并不完整:
And my module-info.java was not really complete:
module AutoGeneratorOpenData {
requires sqlite.jdbc;
requires javafx.controls;
requires javafx.graphics;
requires java.sql;
requires java.desktop;
requires javafx.fxml;
requires javafx.base;
exports autogeneratoropendata;
exports autogeneratoropendata.controller;
exports autogeneratoropendata.model;
exports autogeneratoropendata.util;
opens autogeneratoropendata.controller;
}
现在可以使用了.
这篇关于迁移到 JDK 11 + JavaFX 11 给出 RuntimeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!