Reputation: 53
Hello everyone I am new using jpackage and I am building a java aplicaction with JavaFx framework and I added a Websocket server (using org.eclipse.jetty.websocket and org.eclipse.jetty dependencies) but the application does not start when I double click to the .exe. I am using the following dependencies in my pom file to add the websocket server:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.15</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>11.0.15</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-api</artifactId>
<version>11.0.15</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-server</artifactId>
<version>11.0.15</version>
</dependency>
The application was made in IntelliJ with java 20 and is working fine when i debug and I can interact with the graphical interface and I can connect to the websocket server but when I create app image (.exe) with the following commands:
jlink --verbose --output runtime --module-path "$Env:JAVA_HOME/jmods" --add-modules javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web,java.base,java.desktop,java.instrument,java.logging,java.naming,java.net.http,java.scripting,java.sql,java.xml,jdk.unsupported,jdk.crypto.ec,jdk.accessibility,jdk.management.jfr --strip-native-commands --no-header-files --no-man-pages --strip-debug --compress=1
jpackage --verbose --type app-image --runtime-image runtime --input ../../target/libs --module-path ../../target/mods --module $ModuleAndMainClass --dest . --name $AppName --vendor $Vendor --resource-dir resources --java-options "-XshowSettings:all" --icon resources/$AppName.ico
I get the .exe application successfully but when I double click to the .exe, the process opens but ends immediately without warning or errors and when I create the .exe without websocket and without org.eclipse.jetty, org.eclipse.websocket dependencies, the .exe runs successfully and I can interact with the graphical interface created with Javafx.
I am using Jdk 20.0.2 with javafx framework 20.0.2 and I have installed Javafx jmod in the path %JAVA_HOME%/jmods and I tried the following:
My system environment look fine: JAVA_HOME is the path of my jdk 20 installation folder and the Path has %JAVA_HOME%\bin After that the problem still persists and I have the following questions:
Upvotes: 2
Views: 151
Reputation: 33895
How can I validate the log of the application when it starts if it automatically closes?, Does Java have a way to monitor the execution of an .exe created with jpackage?
You can try running jpackage with --win-console
, and then running the application from the console to see if any error message is printed.
How can I verify that the runtime that is included in the application image can load all the necessary packages for the application to start?
Create the runtime image without the --strip-native-commands
option. That will result in a runtime image that includes the java
launcher. You can then use that launcher to try and launch the application manually, by manually specifying the module path and main module.
Upvotes: 4