hanarce
hanarce

Reputation: 53

Cannot start program created with jpackage

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:

  1. I tried install JavaxFx 20.0.2 framework from libs, copying the .jar files to the %JAVA_HOME%\lib folder
  2. I tried clear cache memory
  3. I tried reinstall Java and JavaFx 20.0.2
  4. I tried disable antivirus when I execute Jpackage and Jlink commands
  5. I tried clear maeven packages repository.
  6. I have already validated that I only have a single version of Java installed(20.0.2) 7.I have already validated that the packages (jmod) are added to the destination folder where the .exe is located, I even copied them manually but the problem persists.
  7. I tried manually downloading javafx jmod packages to include the folder path in the --module-path parameter of the jLink command.

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:

  1. What do I have to include in jlink or jpackage so that I can create the application image and run it with javafx and websocket server (org.eclipse.jetty)?
  2. 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?
  3. 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? Any thoughts will be greatly appreciated. Best

Upvotes: 2

Views: 151

Answers (1)

Jorn Vernee
Jorn Vernee

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

Related Questions