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
views:
833answers:
6Commercial 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.
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:
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.
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 :)