Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Exporting Eclipse to jar (with javafx) not working
Exporting Eclipse to jar (with javafx) not working [message #1826333] Thu, 23 April 2020 16:41 Go to next message
Dominik Wrona is currently offline Dominik WronaFriend
Messages: 7
Registered: December 2019
Junior Member
I have a Java project on eclipse which uses JavaFx for the GUI. Everything works fine in the IDE itself, however when I attempt to export it to something I can share with others (i.e. a jar),my computer refuses to run it.

If I choose to "Package required libraries" I get this error:
Quote:
Graphics Device initialization failed for : es2, 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:830)
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:830)


If I choose the "Extract" option for libraries instead, I get " Error: JavaFX runtime components are missing, and are required to run this application " on my Terminal.

I am using Eclipse version 2019-12 (4.14.0)
Re: Exporting Eclipse to jar (with javafx) not working [message #1826334 is a reply to message #1826333] Thu, 23 April 2020 16:54 Go to previous messageGo to next message
Dominik Wrona is currently offline Dominik WronaFriend
Messages: 7
Registered: December 2019
Junior Member
Update: I tried an independent packager, and it gave me the same error as on the 'Extract' option: "Error: JavaFX runtime components are missing, and are required to run this application". This is despite javafx working in the IDE itself.
Is there an error in how Eclipse interacts/includes the JavaFx?
Re: Exporting Eclipse to jar (with javafx) not working [message #1826347 is a reply to message #1826334] Thu, 23 April 2020 18:42 Go to previous messageGo to next message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 58
Registered: October 2018
Member
Hello,

I had my shares of problems using JavaFX and extracting a runnable jar.

In some cases it works just fine. But there are exceptions...

My remedy:

- The project is Maven based.
- The project use module-info.java .
- When using the "Runnable JAR File Exporter" I use "Copy required libraries into a sub-folder next to the generated JAR"
- I use windows so I create a Batch file (cmd)

Here is a sample:

cd K:\JavaAPPs\Initial.FX
java.exe "-Dfile.encoding=UTF-8" --enable-preview -cp "K:\JavaAPPs\Initial.FX\Initial.FX.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\commons-collections4-4.4.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\commons-lang3-3.10.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-base-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-base-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-controls-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-controls-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-graphics-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-graphics-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-media-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-media-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-web-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-web-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\MyLogger.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\reactive-streams-1.0.3.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\rxjava-3.0.2.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\vavr-0.10.2.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\vavr-match-0.10.2.jar" -p "K:\JavaAPPs\Initial.FX\Initial.FX.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\commons-collections4-4.4.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\commons-lang3-3.10.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-base-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-base-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-controls-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-controls-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-graphics-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-graphics-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-media-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-media-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-web-14.0.1-win.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\javafx-web-14.0.1.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\MyLogger.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\reactive-streams-1.0.3.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\rxjava-3.0.2.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\vavr-0.10.2.jar;K:\JavaAPPs\Initial.FX\Initial.FX_lib\vavr-match-0.10.2.jar" -m Initial.FX/main.MyApplication

Actually I wrote a program to generate the file so it is not so bad....
Re: Exporting Eclipse to jar (with javafx) not working [message #1826360 is a reply to message #1826347] Fri, 24 April 2020 02:40 Go to previous messageGo to next message
Dominik Wrona is currently offline Dominik WronaFriend
Messages: 7
Registered: December 2019
Junior Member
Ok I think I found one reason: I'm using VM arguments to get javafx to work:
--module-path "\path\to\javafx-sdk-13.0.1\lib" --add-modules javafx.controls,javafx.fxml
, and this doesn't get carried into the jar as Eclipse itself says. But how to solve that?
Essentially, perhaps the key to solving this problem is to have javafx working on Eclipse without the VM arguments.
I've heard about Maven but I don't quite know what it is nor how to use it.

Attached are screenshots that I hope can help someone solve the issue.

[Updated on: Fri, 24 April 2020 02:46]

Report message to a moderator

Re: Exporting Eclipse to jar (with javafx) not working [message #1826379 is a reply to message #1826360] Fri, 24 April 2020 07:47 Go to previous message
Eitan Rosenberg is currently offline Eitan RosenbergFriend
Messages: 58
Registered: October 2018
Member
Hello,

IMHO Maven or Gradle is a must for Java programmer.(I have to admit that I started using Maven quite late and I regret it)

Install Maven and then follow this tutorial:

index.php/fa/37934/0/

https://openjfx.io/openjfx-docs/#IDE-Eclipse

The system will download the jars (dependencies) from Maven site and will store them in folder {user.home}\.m2\ .

Since I use 14.0.1 I change the pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>FX.SDK.tests</groupId>
<artifactId>FX.SDK.tests</artifactId>

<version>0.0.1-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14.0.1</version>
</dependency>
</dependencies>

</project>

I was able to create a stand alone runnable jar using "Package required libraries into generated JAR"

This is the content of the jar:

index.php/fa/37935/0/

Maven tip:

I you do not like the default location ({user.home}\.m2\) you can put in .m2

a file settings.xml

in my case I have:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

<!-- See https://maven.apache.org/ref/<version>/maven-settings/settings.html -->
<!-- This file needs to be put in {user.home}\.m2\ (e.g. C:\Users\eitan\.m2 ) -->


<!-- Configuring your Local Repository -->
<localRepository>G:\MyMavenRepo</localRepository>

</settings>
Previous Topic:Annotation Processing
Next Topic:cannot be resolved to a type!
Goto Forum:
  


Current Time: Wed Oct 21 00:16:03 GMT 2020

Powered by FUDForum. Page generated in 0.02804 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top