The main class of your program inherits from Application.
There is a known issue with JavaFX and Gradle that if your main class extends Application, the jar file won't run properly. The solution here, is to make a main class wrapper, such that you have a Main class that calls a method in a Launcher class. Launcher extends Application, and the main method in the Main class can call a launch method in the Launcher class to execute Application.launch().
Here are the possible reasons that I have experienced myself:
JavaFX dependencies are not properly configured. You should add all these under "dependency" in your Gradle build file.
The main class of your program inherits from
Application
. There is a known issue with JavaFX and Gradle that if your main class extendsApplication
, the jar file won't run properly. The solution here, is to make a main class wrapper, such that you have aMain
class that calls a method in aLauncher
class.Launcher
extendsApplication
, and themain
method in theMain
class can call alaunch
method in theLauncher
class to executeApplication.launch()
.