我在Java 8 + JavaFX上有一个要迁移到Java 11的应用程序。其基本目的是为网络上的用户提供.jar,以便他们可以使用此小应用程序。我将JavaFX用于接口,并使用sqlite-jdbc生成数据库。
我有我的module-info.java,编译似乎正常:没有错误。但是,如果我运行该应用程序,则会出现以下错误:
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 …Run Code Online (Sandbox Code Playgroud) 使用 VM 参数运行 JavaFX 应用程序。程序编译并运行。在 MacOS 上使用 Eclipse。当程序运行时,它会在 Dock 中显示 java 咖啡杯徽标,但没有出现窗口。
我希望能够成功运行这个程序。我相信这是一个 Eclipse 配置问题而不是代码。
让 JavaFX 在 Eclipse for Mac 上运行时遇到了很多问题,主要问题是库不存在且无法导入。我能够通过从这里下载 JavaFX ( https://gluonhq.com/products/javafx/ ),在我的项目中创建一个用户定义的库并使用 VM 参数运行程序来使其工作:--module-path /Library/Java/JavaVirtualMachines/javafx-sdk-11.0.2/lib --add-modules=javafx.controls。现在程序可以编译,但我遇到了上述问题。
这篇文章描述了我遇到的问题:https : //discussions.apple.com/thread/7886329
import javafx.application.*;
import javafx.scene.*;
import javafx.stage.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
public class SimpleCalculator extends Application
{
private Label firstValue;
private Label secondValue;
private Label sumLabel;
public void start( Stage myStage)
{
myStage.setTitle( "Simple Calculator");
FlowPane rootNode = new FlowPane();
Scene myScene = new Scene( rootNode, 300, …Run Code Online (Sandbox Code Playgroud)