0

I was able to package my JavaFX application including the JRE using the jpackage tool of Oracle JDK 15, but it needs to be installed first to run natively on Windows. I need my application to run as soon as it is executed, no installation needed.

Is there a way to do this without any third party tools? If not, what are the options?

  • 1
    https://stackoverflow.com/questions/147181/how-can-i-convert-my-java-program-to-an-exe-file does this help? – Mubin Apr 18 '21 at 21:41
  • https://www.ej-technologies.com/products/install4j/overview.html – Victor Gubin Apr 18 '21 at 21:52
  • 1
    Instead of using jpackage, [just jlink it](https://stackoverflow.com/questions/53453212/how-to-deploy-a-javafx-11-desktop-application-with-a-jre) and distribute the image. – VGR Apr 19 '21 at 00:54
  • Using @VGR solution definitely works. But if you still want to use `jpackage` (e.g. for easier handling of non-modules, application icons, JVM/application arguments, etc.) you can use `--type app-image` and distribute the result. Though note [the user guide](https://docs.oracle.com/en/java/javase/16/jpackage/packaging-overview.html#GUID-E0966C49-ABBB-46A2-8DF7-1D3F96640F05) suggests `app-image` is meant more for testing and/or modifying the image before continuing to create an installer. – Slaw Apr 19 '21 at 04:31
  • 1
    Thank you for your suggestions. @VGR I tried your suggestion to use jlink, but the problem is, I'm using a third party jar that is provided by the vendor. The external jar doesn't have a module-info and jlink is showing it as a problem: [WARNING] Required filename-based automodules detected. Please don't publish this project to a public artifact repository! Error: automatic module cannot be used with jlink: toolkit from file:///C:/dev/projects/MyApp/src/main/resources/libs/toolkit.jar I don't have the source code for that jar, its just have compiled classes. Any other suggestions? – Ed Cardenas Apr 19 '21 at 04:45
  • I think https://stackoverflow.com/questions/47222226/how-to-inject-module-declaration-into-jar addresses this. – VGR Apr 19 '21 at 11:18
  • The approach I described using `jpackage` can handle non-modules. – Slaw Apr 19 '21 at 22:14
  • @Slaw, packaging the app as app-image type would create the folder with all the files for the app. I'd like to have only 1 file that runs the application, because users are not technical. Is there a way to package using jpackage that has the option to run the application after installing it? – Ed Cardenas Apr 19 '21 at 22:57
  • `jlink` will give you the same thing (a folder with sub-folders and various files), except without a native executable to launch the application (it only gives you a script to launch the application). As far as I know, `jpackage` can not give you a single file that does not install the application first. You might be able to find something with a third-party (e.g. Launch4J). Though why not have an installer? – Slaw Apr 20 '21 at 00:58
  • @Slaw. Really? hmmm.. Launch4J was my other option. The reason is because we are replacing the legacy C++ application that runs natively on windows, and the customer would want the Java app to behave the same without installing it. – Ed Cardenas Apr 20 '21 at 01:21

0 Answers0