2

Let's say I want to distribute a Java desktop app in a native-like way. Is there a tool/technique to build Java desktop application installers that will automatically and seamlessly install a JVM if one does not exist on a system already?

Installing Java apps for users who do not have a JVM is a 2-step process (first install the JVM, then the app). I'd like to match the experience of installing a typical native desktop app by making it a one-step process (or as much one-step-ish as possible).

  • Which OS are you targeting? – Adam Michalik Sep 15 '15 at 08:10
  • @AdamMichalik I'd like to target all three major Oses. I realize the typical install process is radically different on all three. –  Sep 15 '15 at 08:47
  • Edited my response with a suggestion for Linux. I have no experience with OS X. – Adam Michalik Sep 15 '15 at 08:55
  • Most installers will also support bundling the JVM along with your application, just as you want. Here is a list with more options: http://stackoverflow.com/questions/32539336/how-to-create-exe-from-jar-files-in-java/32539391#32539391 – Bogdan Mitrache Sep 15 '15 at 13:39

1 Answers1

0

For Windows, I suggest using NSIS installer to wrap installation of the JRE and your program. That will allow real "installation", ie. JRE will be installed to Program Files and it will be possible to uninstall it from Windows control panel ("public JRE"). You need to bundle the JRE installer for that.

Alternatively, you can bundle the whole JRE ("private JRE") together with your program. You can use Launch4J which configures the launch of your Java application (VM options, classpath etc.) as an EXE file, have the JRE somewhere as one of the folders of your distribution and point Launch4J to use it.

Or, simply have the unpacked JRE ("private JRE") in one of the folders of your distribution and use relative paths to use that one instead of the one installed on the system.

The advantage of a private JRE is that you control which Java version it is. With a public JRE, the user may be able to uninstall it or change the version and then come complaining that your program is not working ;)

For Linux, if you distribute you application as an RPM, you can just declare a Java package to be your dependency. Linux package manager should take care of it all. On the other hand, you can still bundle JRE in your own RPM to be independent of the "main" version installed on the user's machine.

Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
  • not all linux distributions support RPM. simply providing a tarball that can be unpacked and runs a shell script with a relative path to the JRE probably more portable – the8472 Sep 15 '15 at 21:23