views:

196

answers:

4

Hi I have a java application that I want to release as an exe or dwg etc so that users on different platforms can double click it and get it to start running. But for my code to work really well I need it to work as a windows service and whatever the equivalent of this in other OS are. Using Java web start is not a solution because as I understand it, if the client machine shuts down then the user will have to again double click on the exe. I have tried java service wrapper but I can't see how to make it releasable.

Thanks Pranabesh

A: 

You would need to build a release package for each operating system you were to release on.

For Windows, for example, you will need to find an executable wrapper. It's been a while since I've done this, but I remember usign a couple that would actually build an installer as part of the proccess.

Launch4j is one I've just remembered

jeef3
Yep, Launch4J is a good solution:http://launch4j.sourceforge.net/
Russell
I can make an exe for windows using launch4j but how do I make a dmg for mac?
Sorry, I only ever used it for windows...
jeef3
A: 

Java Service Wrapper is a way to go for Windows/Unix/OSX. I've been using it with no problems for some years. It's a great software and handles JVM crashes/hangs well automatically restarting the service if something bad happens.

What concerns the distribution of the application, I'd recommend NSIS on Windows. It can create a nice installer that will put the files where necessary and run the JSW stub to install the service on the target system. For Unix you can just package it in tar.gz and provide instructions on how to install the service (copy the sh script into /etc/init.d, install it using chkconfig or any other system dependent tool for managing startup scripts). On Mac you should package it into dmg.

You may also try izpack if you want a more cross-platform solution. izpack can run from the java web start, as a native windows application or mac application, check the utilities page.

IzPack is a one-stop solution for packaging, distributing and deploying applications. It is fully cross-platform and generates a single installer. As such, it is an alternative to native solutions such as platform-specific installers and package managers. IzPack-generated installers only require a Java virtual machine to run.

CrazyCoder
+1  A: 

Take a look at -

launch4j.sourceforge.net

ZiG
+2  A: 

If a commercial tool is acceptable for you, I'd recommend install4j. It can produce installers for the most common plaftforms, which specifically support installing the application as a service.

Quote from their 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.

Jonik
Agree, we use this product and build platform specific files for Windows, MAC and Lunix. It also has cool specific options for different OS. As mentioned you can install to windows as a service. The selling point for me is that it also provides a built in mechnisim for automatic updates. It also has a nice api.