views:

833

answers:

6

Hi guys, I need to build an installer that does the following: 1. Installs my jar on the client 2. Auto-detects if JRE is installed (in which case it does not re-install it), otherwise installs it without the user clicking on another button 3. Auto-starts the application when the client is booted 4. Works across Windows, Mac and Linux. Any idea how to go about it? (I am not a technologist - hope I am not asking for the impossible). Thanks

+1  A: 

Commercial tools like InstallAnywhere can do that. After installing the JAR (and links and such), installers can check the registry if Java is already installed and proceed or not. As long as the installer supports all needed plattforms, you are fine.

Peter Kofler
A: 

Haven't heard of anything that works across all those platforms, but JSmooth might help (fits your needs on Windows). I've used it about 2 years ago and it worked fine.

abyx
+4  A: 

If a commercial tool is ok, I can recommend install4j. 1, 2 and 4 are easy to do with it, but about 3 I'm not sure. Edit: You could probably achieve that by installing your app as a "service", which install4j supports for all platforms. Quoting from its Features page:

install4j offers full support for generating and installing services (daemons). For services, install4j generates service executables on Windows, startup items on Mac OS X and start/stop scripts on Unix/Linux platforms.

Edit: Regarding #2, JRE detection: install4 has pretty nice, flexible options for JRE bundling/detecting. You can include a JRE (statically or dynamically, shared or not) or prefer to use one already present, with the possibility to download a JRE from within your installer as a fallback. Check these docs for more: How Installers Find a JRE and JRE Bundles.

(More about my experiences with install4j.)

For other tools, you could check some of the earlier Java installer questions on SO:

Jonik
Noting Peter's answer, by the way, I would *definitely* recommend choosing install4j over InstallAnywhere, which is overpriced and clumsy. We replaced InstallAnywhere with install4j; see the "more about my experiences" link above.
Jonik
+1  A: 

You could use launch4j , it does not automatically install java however. But maybe there's a way to make that work by packaging the JRE for example.

miguelle
A: 

You may also want to take a look at BitRock InstallBuilder, it provides built-in functionality to perform what you want. We will be happy to build a sample installer for you, just drop us a line.

Daniel Lopez
A: 

I recommend downloading the source code for the build scripts of popular Java programs like limewire and follow their example. The end.

...Or you can do like I did:

  • I have done the JRE detection and download/install of redistributable if required with NSIS on Windows. Maybe an .msi is better than a installer.exe which NSIS creates. I believe msi are more like packages on mac so they allow proper updates. Maybe NSIS creates MSIs... not sure.
  • Mac is simply an Java App bundle and you specify the JRE and other Java info in the info.plist and you can optionally create a .pkg file to give the user an installer and bundle up in a dmg using the command line dmg programs.
  • I haven't done Linux and don't plan to... sorry :)

All this was a fair chunk of work. I first did the Windows stuff then a couple years later did the Mac stuff.

You can integrate all of this in NSIS build scripts and Ant. I can't remember why I didn't use install4j. Probably I was too cheap :)

Cal