Creating an installer for Java desktop application

末鹿安然 提交于 2019-12-02 14:56:41

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 trailed on and off before (but when it comes to spending money, you tend to want to know you're getting what you want ;))

Andrew Thompson

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.

I was in the same situation a few months ago. After trying out a lot. I suggest NSIS. There is a nice plug-in for Eclipse EclipseNSIS with some templates. It helps a lot to get a basic installer with just some easy clicks. If the resulting code is not sufficient you can do the rest work by coding, but most of the code is generated by EclipseNSIS.

You can also use Advanced Installer. Since you already have an EXE to launch your JAR, you don't need to use the Java Launcher support from Advanced Installer, you can create a Simple project, which is available in the free edition, so you don't need to purchase a license.

It will take you maximum 10 minutes to install it and create the setup package, as you will see it is very easy to learn using 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. This can inherently create installers for Linux, Mac and Windows operating system.

An EA of the tool is already available as a part of the JDK.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!