Facing "NoClassDefFoundError" when running Gradle-generated JAR for JavaFX app. Gradle build succeeds, but JAR execution fails due to missing "javafx/application/Application" class. Need help including JavaFX in JAR build.
Here is the error:
Error: Could not find or load main class com.jamal1aarab.Main Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
Here is part of my build file where I think the problem is:
mainClassName = 'com.jamal1aarab.Main'
jar {
manifest {
attributes(
'Main-Class': 'com.jamal1aarab.Main'
)
}
}
The directory is correct at src\main\java\com\jamal1aarab
I configured my Gradle build with the main class and manifest attributes. Gradle build and run work fine, but when I try running the JAR, the "NoClassDefFoundError" pops up. I expected my JavaFX app to run smoothly from the JAR, just like it does through Gradle. However, the missing "javafx/application/Application" class caused the JAR execution to fail.
Also, I've come across numerous Stack Overflow posts discussing similar issues. However, most solutions seem to involve fixing the path, which I've already ensured is correct in my case.