Samuel Šouc
Samuel Šouc

Reputation: 1

Problem building and running JavaFX .jar file

I have hard time making my JavaFX app run outside of my IDE. I am using IntelliJ IDEA 2019.3, and compiling using openjdk-12. Version of JavaFX sdk is 11.0.2 and I use external libs jfoenix-9.0.8 and jSerialComm-2.6.0. Operating system is Windows 10, installed JDK 14 and I am able to run non-JavaFX apps built same way using command line java -jar name.jar. When I try to run mu JavaFX .jar from command line, I get this Error message:

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 com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:280)
        at com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:222)
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:260)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:94)
        at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
        ... 1 more
Exception in thread "main" java.lang.RuntimeException: No toolkit found
        at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
        at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:678)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:832)

All required libraries are included in .jar as far as I can tell, I followed along multiple threads and tried multiple things but I always end up stuck, as I am quite new to building Java .jar-s..

Also tried following tutorial at openjfx official page where I ran into problem when tried compiling my app both modular and non-modular way, due to the external libraries.

dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX%;%PATH_TO_FOENIX% --add-modules=javafx.controls --add-modules=javafx.fxml --add-modules=jfoenix-9.0.8.jar --add-modules=jSerialComm-2.6.0.jar --add-modules=javafx.graphics -d out @sources.txt & del sources.txt

Using this command in Win cmd I get an error:

error: bad name in value for --add-modules option: 'jfoenix-9.0.8.jar'
error: bad name in value for --add-modules option: 'jSerialComm-2.6.0.jar'

PATH_TO_FX is set to the correct location by following tutorial and PATH_TO_FOENIX is set to location with exteranl libraries .jar-s. Tried this command also without ".jar" at the end of lib name.

When I create module-info.java in folder corresponding to the module I can actually compile it using command:

dir /s /b src\*.java > sources.txt & javac --module-path %PATH_TO_FX%;%PATH_TO_FOENIX% -d mods/LA_GUI @sources.txt 

but then I get error:

Error: Module javafx.fxml not found, required by LA.GUI

when I try to use jlink to build image. The sample providet at openjfx is very simple so I may be omitting something here. And that's that. Tried adding framework support for Maven in Intellij but then Maven has problems finding different packages and after each solved error trying to run Maven test there came another so I gave up on that either as I never used it before and had no idea if I even could make it work and if the .jar generatet using Maven would be any different from one I have now..

Side note: I removed latest JRE from my laptop because when I tried running even hello world programs via java -jar name.jar, it said that the file was compiled using newer version than current java can run, which makes no sense as I downloaded LATEST JRE. Right now I have all java associated variables and runnables to JDK 14, which runs basic java programs just fine but I cant seem to make it run my JavaFX .jar without the aforementioned error. I would have swap to other programming language suited for building GUI apps, or used Java Swing or something, but I have less than month to finish this project and cant afford to start over with something I haven't used before..

EDIT: This is screenshot of contents of my .jar file I try to run: .jar file contents

Upvotes: 0

Views: 739

Answers (1)

David Bates
David Bates

Reputation: 31

I experienced error messages by following the example from OpenJFX. I found if I swapped the order from (--module-path --add-modules) to (--add-modules --module-path), I was able to make it work. Also, I had to provide the full address of the module-path versus using the environment variable. Hope that gives you some ideas.

Upvotes: 0

Related Questions