I'm using Java 8 with JavaFX. When I package my executable JAR with maven, the executable JAR works fine using Java 8. However, if I run the JAR with e.g. Java 13, I get the following error:
Error: Could not find or load main class ApplicationLauncherClient
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
This is presumably caused by JavaFX not being bundled with the JRE/JDK anymore since Java 11.
My pom.xml build configuration looks as follows:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>ApplicationLauncherClient</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
My goal is to instruct maven to build a JAR which can run on any Java version greater than or equal to 8 by including JavaFX in the executable JAR.
I did not succeed with following the instructions in this answer (by e.g. adding the JavaFX plugin to my pom.xml). Including OpenJFX as dependency also did not work, I still receive the same error.