I\'m getting this error
Exception in thread \"main\" java.lang.NoClassDefFoundError: javafx/application/Ap
plication
at java.lang.ClassLoader.defineC
I know it may not be the "proper" way of launching an javafx application but i have struggled with this problem for some time and came up with a workaround that does not require to use any external packaging applications, force you to use ant or maven plugin (which conflicts with the shade plugin) etc...
The solution uses Utils4j to load jfxrt dynamically at runtime. You cannot load it in a class extending javafx.application.Application, do it in a separate class and name it for example: Launcher
import org.fuin.utils4j.Utils4J
public class Launcher {
public static void main(String[] args) {
Utils4J.addToClasspath("file:///"+System.getProperty("java.home")+ File.separator+"lib"+File.separator+"jfxrt.jar");
// CODE TO RUN YOUR CLASS THAT EXTENDS javafx.application.Application goes here.
}
}
you can include Utils4j with your project (if using maven):
org.fuin
utils4j
0.7.0