Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Method to run a Java Application as a *nix Daemon or Windows Service?

Tags:

I am looking for the best method to run a Java Application as a *NIX daemon or a Windows Service. I've looked in to the Java Service Wrapper, the Apache Commons project 'jsvc', and the Apache Commons project 'procrun'. So far, the Java Service Wrapper looks like it's the best option... but, I'm wondering if there are any other "Open Source friendly" licensed products out there.

like image 495
Matt Cummings Avatar asked Aug 25 '08 01:08

Matt Cummings


People also ask

Does Java run as a service?

You can install any Java application as a service. Usually, you install applications that run forever like an HTTP server in this case. We use the application as is with just a small change.


2 Answers

I've had great success with Java Service Wrapper myself. I haven't looked at the others, but the major strengths of ServiceWrapper are:

  • Great x-platform support - I've used it on Windows and Linux, and found it easy on both
  • Solid Documentation - The docs are clear and to the point, with great examples
  • Deep per-platform support - There are some unique features in the window service management system that are supported perfectly by service wrapper (w/o restarting). And on Windows, you will even see your app name in the process list instead of just "java.exe".
  • Standards Compliant - Unlike many ad-hoc Java init scripts, the scripts for service wrapper tend to be compliant with LSB standards. This can end up being very important if you ever want high availability management from something like Linux Heartbeat/HA.

Anyway, just my 2 cents... :)

like image 137
jsight Avatar answered Sep 28 '22 05:09

jsight


Another option is WinRun4J. This is windows only but has some useful features:

  • 32 bit and 64 bit support
  • API to access the event log and registry
  • Can register service to be dependent on other services (i.e serviceA and serviceB must startup before serviceC)

Its also open source friendly (CPL) so no restrictions on use.

(full disclosure: I work on this project).

like image 32
Peter Smith Avatar answered Sep 28 '22 07:09

Peter Smith