4

I have encountered many different ways to turn a Java program into a Windows Service or a *nix daemon, such as Java Service Wrapper, Apache Commons Daemon, and so on. Barring licensing concerns (such as JSW's GPL or pay dual-license), and more advanced features, which one would you recommend? All I intend to do is convert a simple Java program into a service; I don't need anything fancy, just something that runs as a service or a daemon, so I can start it or stop it in the service manager, or it runs for the lifetime of my *nix uptime.

EDIT:

I've decided to make this community wiki. I didn't start this question with an intention to find an answer for a problem I really had. I was just doing some reading and researching and chanced upon this question, so I was looking for recommendations and the like. Sorry for not doing this sooner or doing this at first. I didn't know what community wiki was for when I first started, and I completely forgot about this question until now. Many thanks for the answers!

blwy10
  • 4,862
  • 2
  • 24
  • 23
  • Possible duplicate of http://stackoverflow.com/questions/25530/best-method-to-run-a-java-application-as-a-nix-daemon-or-windows-service – Raedwald Nov 26 '13 at 21:03

2 Answers2

2

I've used JavaService for years and have been very happy with it. Very simple.

That said, we're switching to JSW for the next major release - its multi-platform support is awesome. Also, having all of the params in a .conf file vs the Windows registry is a major plus. But if you're only looking at Windows, JavaService might be a good way to go. (no experience with Apache Commons Daemon)

CarlG
  • 1,656
  • 1
  • 17
  • 21
1

On Unix, I tried and quite liked daemontools when I set up a VPS to run Tomcat instances.

Using daemontools, I could write a fairly simple start script and have the Tomcat process run as part of my regular system startup routines. I was running several different Tomcats under different user IDs, to support private JVMs for a couple of sites.

Of course, this is all possible with a SysV style init script that runs jsvc, but having tried the former I found it much easier to set up the daemontools alternative. Also, I was using daemontools across the board for a VPS to try to reduce resource usage as much as possible. The biggest downside to daemontools was I couldn't find a way to indicate a dependency between services easily, but it hasn't caused problems in the end as nothing falls over just because it takes a few extra seconds for the database to start.

William Rose
  • 971
  • 1
  • 6
  • 13