I have a Java (JavaFX) application that has been built using Gradle on Laptop A. When I deploy it to Laptop B it fails to run throwing the following Exception:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: javafx/fxml/FXMLLoader
at main.Main.start(Main.java:85)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
... 1 more
Caused by: java.lang.ClassNotFoundException: javafx.fxml.FXMLLoader
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 10 more
I used the gradle pluggin to build an executable jar. It also built a zip and tar file. The zip (and tar) file contains a bin directory with a script to run the application and a lib directory containing loads of jar files.
I had a previous issue
Error: JavaFX runtime components are missing, and are required to run this application
I found a solution here:
Maven Shade JavaFX runtime components are missing
I created a wrapper class with a main (non javafx) that calls the main (javafx).
My current problem:
Clean install of Linux Mint - 19.3 Cinnamon Kernal - 5.3.0-53-generic
gradle-6.0.1
Java version -
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)
If I use the script from the (exploded) zip file:
./MyApp/bin/MyApp config.json
Or just execute the app:
java -jar MyApp.jar config.json
These both fail
Using the ZIP file content I explored the jar files gradle deployed.
MyApp.jar
* javafx-graphics-11.jar
* javafx-base-11.jar
javafx-controls-11-linux.jar
javafx-graphics-11-linux.jar
javafx-base-11-linux.jar
joda-time-2.10.5.jar
The '*' files are proxies and only contain a MANIFEST. The 'linux' jars contain the JavaFX classes however NONE of the files contain: javafx.fxml.FXMLLoader
My - build.gradle
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
javafx {
version = "11"
modules = [ 'javafx.controls' ]
}
repositories {
mavenLocal()
mavenCentral()
}
sourceCompatibility = '11'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty('mainClass')) {
ext.mainClass = 'Main'
}
mainClassName = "Main"
run {
args 'config.json'
}
dependencies {
compile "joda-time:joda-time:2.10.5"
testCompile "junit:junit:4.12"
}
jar {
manifest {
attributes 'Main-Class': 'Main'
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
Can any one please see what I am doing wrong. This application needs to run on a clean system with no expectetaions other than Java (preferably OpenJDK).
I would also like it to run on a Windows 10 platform so can anyone tell me how to get the gradle build to include the 'win' equivilant jar files:
javafx-controls-11-win.jar
javafx-graphics-11-win.jar
javafx-base-11-win.jar
Kind Regards
Stuart