jpackage Failed to Launch JVM with 3rd party jars without jmods
-
Hi!
I am trying to make an exe for my Java project, and for that I tried to use the following cmd:
jpackage -t app-image --name "App Name" --vendor "Vendor" --app-version 1.0 --input "E:\Jar" --dest "E:\Release" --main-jar "My App.jar" --icon "E:\Icon.ico" --module-path "C:\Program Files\Eclipse Adoptium\jdk-21.0.8.9-hotspot\jmods;E:\ProgramUse\Java\JavaFX\javafx-jmods" --add-modules java.base,java.datatransfer,java.desktop,java.sql,javafx.base,javafx.controls,javafx.graphics
But when the exe is made I get "Failed to Launch JVM".
If I use that cmd on a different project it is working fine. BUT the main difference is that the other project doesn't have 3rd party jars other then JavaFX for which I have the jmods.
For the project with the problem I am using other jars as well, and when I am running:
jdeps --multi-release 21 --list-deps --ignore-missing-deps --module-path "E:\ProgramUse\Java\JavaFX\sdk\lib;E:\ProgramUse\Java\Jars\ProjectRequired" "E:\Jar\My app.jar"
I get this:
jakarta.mail java.base java.datatransfer java.desktop java.sql javafx.base javafx.controls javafx.graphics org.bouncycastle.lts.prov
And from that I guess the problem is jakarta.mail and org.bouncycastle.lts.prov.
How do I handle this scenario? I do not have the jmods for both of them. All the jars are included in the runnable jar made by Eclipse.
-
So it turns out that I was getting that error because of connection to DB which was in void main for testing, but now I moved it on a button press:
con = DriverManager.getConnection(db, userDB, passDB);
The thing is, in Eclipse it is working fine, but in packed form, when I call that it just hangs, it doesn't advance. I did a little test around it and the status stays at "Starting connecting".
statusDB.setText("Starting connecting"); Thread thread = new Thread(new Runnable() { public void run() { try { con = DriverManager.getConnection(db, userDB, passDB); Platform.runLater(new Runnable() { @Override public void run() { statusDB.setText("Connected"); } }); } catch (Exception e) { e.printStackTrace(); FunctionsCode.writeError(e); con = null; Platform.runLater(new Runnable() { @Override public void run() { statusDB.setText("Failed"); } }); } } }); thread.start();
I am using PostgreSQL. Why does it hang in packed form?