Creating an installer for Java desktop application

Edit: I'll leave this here for reference, but note: The Java plug-in needed to launch JWS and applets was removed by browser manufacturers, and both were deprecated in Java 9 and removed from the API.

Use Java Web Start.

Like, pressing Next for 2 - 3 times (which shows all the terms and conditions etc)

The ExtensionInstallerService of the JNLP API provides this. Here is a demo. of the installer service.

..then a user specify a location(like C:\Program Files\New Folder\My App), ..

The ExtensionInstallerService provides a method getInstallPath() which..

Returns the directory where the installer is recommended to install the extension in. It is not required that the installer install in this directory, this is merely a suggested path.

That is not quite the same as what you are asking, but then I think it is generally a bad idea to allow the user that level of control.

then my .exe, lib folder, img folder, other important folders get pasted in the destination folder along with the .exe file ..

JWS installs the resources mentioned in the JNLP automatically, as and when they are needed. Further, it updates the resources if the archives on the server change.

and then a shortcut is created on a desktop.

JWS can supply desktop shortcuts and menu items on supported systems.

E.G.

  • From How to run Java programs by clicking on their icon on Windows?
  • This answer, which shows a JWS app. installed in 'Programs and Features', with the desktop icon to the left of it.

If you are on JDK 13 or above, you can package any Java program along with its runtime by using the default packaging tool in the JDK called jpackage.

jpackage can create installers for Linux, Mac and Windows operating system.

You can create a specific runtime by using jlink.

jpackage needs some 3rd party free software for creating Windows bundles:

* To create .exe bundle, it uses Wix

* To create .msi bundle, it uses Inno

  • Wix is now the only dependency to create both exe and msi bundles.

All the details about jpackage can be found at JEP 343: Packaging Tool.


I have been using InnoSetup for a long time. It has always worked very well. It can do everything you need (unpack files, put shortcuts on desktop, start menu etc) and generates installers that we are used to.


If you want free and open source, you could take a look IzPack. We use this at work for its command line support in our builder.

You could also take a look install4j which is a commercial product we've trialed on and off before (but when it comes to spending money, you tend to want to know you're getting what you want ;))