0

Good Afternoon everyone.

I'm having a problem when I try to run my Java Code as a Runnable Jar file. I'm using Eclipse and I created a normal Java Project. I included the JavaFX jars as a User Libary. The Program runs without a problem when I start it with the IDE. To create the Jar file I use the the build in Export of a Java Project in the Runnable Jar file. When I check "Extract required libaries into generated JAR" and run it, I get this Error Message:

Error: JavaFX runtime components are missing, and are required to run this application

When I check "Package required libaries into generated JAR" and run it, 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:244)
        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:835)
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.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:567)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: 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:835)

Does anyone know, why I cannot run the JAR but in the IDE it runs normally?

I installed JavaFX following the Documentation here https://openjfx.io/openjfx-docs/ .

Patty23
  • 53
  • 1
  • 6

2 Answers2

3

I found a solution to my Problem. When I Export the Libaries into the Generated Jar I got the Error that the JavaFX Runtime components are missing. I now remembered that I got the same Error in Eclipse before although there was no Error in the Code and I used JavaFX elements. But to get it up and running I had to add VM Arguments. So I only had to write this in the command promt when I wanted to run the program.

Assuming you already are in the directory of your build Jar file:

java --module-path "C:\Path\to\javafx-sdk-13.0.2\lib" --add-modules javafx.controls,javafx.fxml -jar YourJar.jar

It's working now for me. Hope it will help others too.

Best Wishes

Patty23
  • 53
  • 1
  • 6
  • Hi, I tried the solution you posted and it works for me, however, why does it not work when I include the javafx.controls and javafx.fxml into the generated jar? Why must it be added as module in command prompt? – YHStan Jun 15 '21 at 07:49
  • Also, found this where you package the JavaFX dll into the jar, then you do not need to add modules in command prompt https://www.youtube.com/watch?v=HuFOCEHh8Zg – YHStan Jun 15 '21 at 08:38
0

Check your built jar file manifest file to see what are its dependencies. There will be an variable called Class-path: U can do this by right clicking on the jar file and opening with winrar or normal explorer META.INF If they all begin with libs/ then create an libs folder where your built jar file is located and copy all javafx specified jar files into that folder and then execute

Sync it
  • 1,180
  • 2
  • 11
  • 29
  • `Manifest-Version: 1.0 Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader Rsrc-Class-Path: ./ javafx.base.jar javafx.controls.jar javafx.fxml.jar javafx.graphics.jar javafx.media.jar javafx.swing.jar javafx.web.jar ja vafx-swt.jar activation.jar jsoup-1.11.3.jar mail.jar Rsrc-Main-Class: fxGui.Gui Class-Path: .` – Patty23 Mar 13 '20 at 06:22
  • That is in the MANIFEST.MF File – Patty23 Mar 13 '20 at 06:22
  • And the libaries of javafx are not in a folder. So I have to put them into a libs folder? – Patty23 Mar 13 '20 at 06:24
  • Oh I assumed they would be in a lib folder but in your case it is simpler. Just copy all the specified jar files into the same directory of your built jar file and deploy – Sync it Mar 14 '20 at 19:00
  • 1
    The ./ May indicate that your app expects these jar files in the parent directory of your working folder. So try copying those files to the parent directory as well and see what works for you but no need for a lin folder – Sync it Mar 14 '20 at 19:09
  • @R VISHAL what ist the parent directory? Or how do I find it? – Patty23 Mar 16 '20 at 10:18