I have a little maven test project to build a very simple javaFX application. I have set up maven that it creates (install task) a .jar file including all dependencies for this project. Since javaFX is not part of the standard JREs/JDKs is thought that would be a good idea.
I was already able to successfully start the application on my Windows10 PC just by double-clicking on the jar with the dependencies. Building it without the dependencies results in an error, since javaFX is missing in the JRE. So far so good.
However, sitting on my Manjaro Linux PC now, i am unable to start the application.
The code for the project is 100% identical (just cloned the repo). Double clicking the .jar doesn't work, neither does trying to execute it from a terminal with "java -jar APP", leading to the error "Used javaFX components missing". What am I missing here, the dependencies should be bundled to the .jar, furthermore it is working under Windows? Btw I am using JDK 12.0.2 on Linux.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>iffuw</groupId>
<artifactId>javaFX-test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- build a jar with all dependencies -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-base -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
</dependencies>
</project>
Furthermore my default java version has the javaFX libs:
ls -l /usr/lib/jvm/java-12-openjdk/lib | grep javafx
-rw-r--r-- 1 root root 744481 17. Aug 18:39 javafx.base.jar
-rw-r--r-- 1 root root 2508117 17. Aug 18:39 javafx.controls.jar
-rw-r--r-- 1 root root 125617 17. Aug 18:39 javafx.fxml.jar
-rw-r--r-- 1 root root 4349165 17. Aug 18:39 javafx.graphics.jar
-rw-r--r-- 1 root root 263870 17. Aug 18:39 javafx.media.jar
-rw-r--r-- 1 root root 113 17. Aug 18:39 javafx.properties
-rw-r--r-- 1 root root 87714 17. Aug 18:39 javafx.swing.jar
-rw-r--r-- 1 root root 36678 17. Aug 18:39 javafx-swt.jar
-rw-r--r-- 1 root root 702059 17. Aug 18:39 javafx.web.jar
-rwxr-xr-x 1 root root 26288 17. Aug 18:39 libjavafx_font_freetype.so
-rwxr-xr-x 1 root root 18024 17. Aug 18:39 libjavafx_font_pango.so
-rwxr-xr-x 1 root root 18024 17. Aug 18:39 libjavafx_font.so
-rwxr-xr-x 1 root root 239280 17. Aug 18:39 libjavafx_iio.so
What am I missing here?
EDIT
Sorry I simply don't get it. The project with the above pom.xml works perfectly on a Windows10 PC! Building it in my Manjaro Linux and using "java -jar APPLICATION" always throws an error like "Necessary JavaFX classes missing". Why does it execute on Windows and not on Linux?
Is there a best practice to build a JavaFX application using maven that definitely runs on all systems where a basic JRE is installed?
EDIT_2
I've just discovered, that under Windows10 I can just start the application by double clicking it. From a cmd "java -jar APPLICATION" yields the same error as under Linux "Error: JavaFX runtime components are missing, and are required to run this application". But omitting the "java -jar" in the cmd, the program starts. Trying to start it under Linux omtting the java -jar by "./APPLICATION.jar" I get an error "Cannot execute binary: Error in file format".
EDIT_3
So i managed to modify the application so, that one can run it (both after building it on linux and windows) via "java -jar APPLICATION.jar". The building of a single jar with all the dependencies worked. A suggestion from one of the commented questions made the deal. I had to "clean" the Main.java so that it does not extend the Application from JavaFX. Simply creating a "NewMain" which extends nothing and just calls Main.main(args) was the solution.
However, this solution is quite a workaround, is this really the only option?