28

I know this question has been asked many a times and all the time there is an answer which says about using an executable jar or making an .exe using launch4j or similar app.

I may sound like a novice, which I actually am.

I have been trying a few things with a Java project. I have successfully made an executable jar and also an .exe file from it. All thanks to your previous answers in SO :)

But, I want to create a installer for Windows. Like, pressing Next for 2 - 3 times(which shows all the terms and conditions etc), then a user specify a location(like C:\Program Files\New Folder\My App), then my .exe, lib folder, img folder, other important folders get pasted in the destination folder along with the .exe file and then a shortcut is created on a desktop.

Any pointers to how can I achieve this ?

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
  • One of the my project I used Nsis as installer. You can check it http://nsis.sourceforge.net/Main_Page. – bhdrkn Feb 04 '13 at 10:59
  • WiX is also a good option. – 1615903 Feb 04 '13 at 11:02
  • 2
    You may also want to check out JWrapper.com, my company recently released it. It is very easy to use, is written in pure Java (so runs on any OS) and generates native apps for Mac, Windows and Linux including icons (from PNGs you provide) and signing if you have certificates for Window and Mac. – AntonyM Feb 05 '13 at 12:10

8 Answers8

21

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.

Adam Dyga
  • 8,666
  • 4
  • 27
  • 35
  • Hi i am using innoSetup and Wix in NetBeans for native packaging,it is not creating a desktop shortcut and not changing the application icon. need help. – Aman Deep Dec 20 '18 at 03:14
8

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 ;))

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
  • +1 for izpack, we use it to build installers for http://gate.ac.uk. It can be a completely scripted process - I have our Jenkins CI server set up to build an installer as part of the nightly snapshot build. – Ian Roberts Feb 04 '13 at 11:51
6

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.

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
4

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
1

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.

NormanC
  • 41
  • 3
0

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.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
0

use Launch4j to create exe file. you must give the relative path to jre folder. next use Inno Setup to make setup. You can bundle jre inside the installer. I've use it and it works like a magic. I can show details.

0

I wanted to share another project. This project have two part:updating your desktop app and ready installers for mac os, linux, windows. If you want only installer so you can adopt for your needs documentation in this way you should replace starter-core-1.0.jar with your jar