Search code examples
javaexeportable-executablejpackage

How to make a portable executable file using JPackage?


I'm using JPackage (OpenJDK 15.0.1) to make a portable executable file for Windows. I tried the command below, but I double-clicked the generated exe file and the installer window was displayed. It seemed that it was not portable executable but just installer.

jpackage --name "Test App" --vendor "com.example" --type exe --input input --main-jar test-app-1.0.jar --main-class main.Main

Is there any way to make a executable file that can be used without installing using JPackage?


Solution

  • If by 'portable executable' you mean a single self-contained executable, then this is currently not possible to do.

    What you can do if you want an executable that can run the program directly without installing, is use the --type app-image flag, which will create an application image that contains a .exe launcher to launch the app.