Does anyone have any up-to-date steps on how to build a complete JAR file which includes JavaFX (hopefully using IntelliJ IDEA and Maven)? I feel like I'm going around in circles trying to piece together bits of information from here, there and everywhere, but I'm yet to create a working JavaFX JAR file.
From my pom.xml I've tried this (com.whatever.App is where my main method is, of course):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<!-- It makes no difference which of these two manifest configs I try -->
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.whatever.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
I can run the "javafx:run" configuration from the IntelliJ IDEA Maven tool window and the program runs just fine, but not "jar:jar". It results in a 345KB JAR file (which looks suspiciously small!) that ends up with this error when I try "java -jar whatever.jar":
Error: Could not find or load main class com.whatever.App
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
My src/main/resources/META-INF/MANIFEST.MF file has the following:
Manifest-Version: 1.0
Main-Class: com.whatever.App
I also tried the shade plugin but it complains thusly:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default-cli) on project whatever: Failed to create shaded artifact, project main artifact does not exist.
Here's the relevant shade config from my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
If I run "mvn package" myself (after adding the shade config above) from the command-line using the latest Maven downloaded myself (because running the goals myself from the Maven tool window in IDEA seems to be not doing everything I would hope), it seems to go through a lot of motions successfully and produces an 11,996KB JAR file (which is bigger, at least), but running it results in this error:
Error: JavaFX runtime components are missing, and are required to run this application