I package a JavaFX application using maven and OpenJDK 1.8 The relevant part from my pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ui.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Now importantly this used to work. I know this because I specifically made a git commit where the packaging finally worked. After a day or so and multiple builds like this (I can't figure out what changed), I can no longer launch the jar because of the following error:
$ java -jar target/app.jar
Error: Could not find or load main class ui.Main Caused by:
java.lang.NoClassDefFoundError: javafx/application/Application
When I view the contents of the Jar, I can see that all dependencies are specifically included, except the JavaFX classes.
What I've tried:
- Build the jar with
javapackager
- Tinker around with the javafx-maven-plugin
- Explicitly add JavaFX as dependency in my pom.xml in the hopes that the assembly-plugin would package it for me
None of the above was successful. The only way I'm able to launch my app is directly out of the IDE, which seems to mean that the JavaFX libs are still available on my system.
Any ideas on how to get this to run (again)?