迁移到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
我的模块-info.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 x64bits和 JavaFX Windows上使用Netbeans 9 SDK (最新版本11)。我不是在使用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?
推荐答案
所以,有一些遗失的图书馆。
So, there are some missing librairies.
-
在Windows上,缺少的DLL来自javafx-sdk-11 / bin 至少是prism_d3d.dll,prism_sw.dll,javafx_font.dll,glass.dll;你可以将所有内容放入jdk目录
C:\Program Files \ Java \ _ddk [...] \ bin
(这不是最好的解决方案),或者进入自定义JRE的jlink目录,在里面。[...] \ jlink \bin \
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 Files\Java\jdk[...]\bin
(It's not the best solution), or into the jlink directory for a custom JRE, inside.[...]\jlink\bin\
在Linux上,javafx-sdk-11 / lib 中缺少的.so至少是libprism_es2.os,libprism_sw。所以,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 - 无需使用librairy文件。
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屋!