Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migration to JDK 11 + JavaFX 11 giving RuntimeException

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.

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

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;
}

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?

like image 541
Drimux Avatar asked Oct 25 '18 09:10

Drimux


People also ask

Does JavaFX run on JDK 11?

For JDK 11 and later releases, Oracle has open sourced JavaFX. You can find more information at OpenJFX project.

Why is JavaFX no longer supported?

JavaFX was removed from JDK since JDK 11. Since JDK 9, java is modular. JavaFX was split into modules. Hence there is no longer a single jfxrt.

Is JavaFX a crossplatform?

Because the JDK is available for all major desktop platforms (Windows, Mac OS X, and Linux), JavaFX applications compiled to JDK 7 and later also run on all the major desktop platforms. The cross-platform compatibility enables a consistent runtime experience for JavaFX applications developers and users.

Is JavaFX a JRE?

JavaFX and Java SE versions Starting with JavaFX 2.2 and Java SE 7 update 6 (7u6), the JavaFX libraries are part of Oracle JRE 7.


1 Answers

So, there are some missing librairies.

  • 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\ .

  • 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 .

  • 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].

To use the jlink, you should use the jmods - no need to use the librairy files.

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;
}

Now it's working.

like image 160
Drimux Avatar answered Sep 17 '22 15:09

Drimux