I am trying to generate a jar file by embedding within it the javaFx dependencies needed to run my program.
Below is my pom.xml file that includes the shave plugin which should do exactly that.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>SoftwareRtf</artifactId>
<version>1.0-SNAPSHOT</version>
<name>SoftwareRtf</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics </artifactId>
<version>11</version>
<classifier>mac</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>20-ea+9</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example.softwarertf.MenuExample</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Later from the command line I ran:
mvn package
In doing so, two files are generated: original-SoftwareRtf-1.0-SNAPSHOT.jar and SoftwareRtf-1.0-SNAPSHOT.jar
That by executing them using the command:
java -jar ....
produce this error
Error: JavaFX runtime components are missing, and are required to run this application
Using the following command I was able to see what is contained in the jar file and I see the JavaFx files inside them.
mvn dependency:tree -Ddetail=true
com.example:SoftwareRtf:jar:1.0-SNAPSHOT
\[INFO\] +- org.openjfx:javafx-controls:jar:17.0.2:compile
\[INFO\] | +- org.openjfx:javafx-controls:jar:mac-aarch64:17.0.2:compile
\[INFO\] | - org.openjfx:javafx-graphics:jar:17.0.2:compile
\[INFO\] | +- org.openjfx:javafx-graphics:jar:mac-aarch64:17.0.2:compile
\[INFO\] | - org.openjfx:javafx-base:jar:17.0.2:compile
\[INFO\] | - org.openjfx:javafx-base:jar:mac-aarch64:17.0.2:compile
\[INFO\] +- org.openjfx:javafx-media:jar:20-ea+9:compile
\[INFO\] | - org.openjfx:javafx-media:jar:mac-aarch64:20-ea+9:compile
\[INFO\] +- org.openjfx:javafx-fxml:jar:17.0.2:compile
\[INFO\] | - org.openjfx:javafx-fxml:jar:mac-aarch64:17.0.2:compile
\[INFO\] +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
\[INFO\] | +- org.opentest4j:opentest4j:jar:1.2.0:test
\[INFO\] | +- org.junit.platform:junit-platform-commons:jar:1.8.2:test
\[INFO\] | - org.apiguardian:apiguardian-api:jar:1.1.2:test
\[INFO\] - org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
\[INFO\] - org.junit.platform:junit-platform-engine:jar:1.8.2:test
I don't understand what I am doing wrong, could it be some necessary module that was not included? Any input is welcome. Thank you!