Issue
I've made a simple program that uses JavaFX and JDBC as dependencies, I packaged it to an installable file using jpackage, with no difficulties, but when I try to launch my program it gives me the following error :
"Missing JavaFX application class com.example.mvnwithjdbcnotused.HelloApplication"
PS: the program is runing fine in the IDE, also with CMD (runing the ".jar" file not the installed file), it's just the resulted .exe file that gives that error. i tried to make the same program but without calling or using mysql database, and it worked fine, so i assumed the problem is related to the dependency (which is MySQL JDBC) or the way i used the Jpackage tool
Steps i followed to create the installable .exe
1-i packaged my files using Intellij's artifact (including all the dependencies used)
2-i used jpackage tool as follow :
jpackage --name "name of the file" --description "description" --vendor "vendor" --app-version 1.0 --input "the file that has the .jar created by the first step" --main-jar "name of the jar"--dest "destination file " --module-path "path to javafx jmods files " --add-modules javafx.controls,javafx.fxml --win-console
3-install the file
4-run the program
I'm really confused if the issue is from the steps i followed or from the dependency or the tool
the last think i want to mention is my project is modular, but MySQL JDBC is not.
Solution
You should edit your question with more details, and when I am near my PC will update this answer.
In order for jpackaged exe to run JavaFX with JDBC your jpackage app must contain the all the dependent jar or modules. One way is to use jlink to collect your dependent modules as one image. Jpackage does this implicitly or you can see this answer. Include jdbc drivers in jlink command if they are modular. Test your own application works with the JRE created by jlink.
how can I get javafx 14 to compile and run?
Then use this jlink image in jpackage.
How can I convert my Java program to an .exe file?
Additional jar dependencies must also be copied into the image using --input
. Setup a jpackage.image
folder with additional classpath jars, property files etc which can be used within cfg
files as $APPDIR
Answered By - DuncG
Answer Checked By - Candace Johnson (JavaFixing Volunteer)