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

半城伤御伤魂 提交于 2019-11-29 01:14:57

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... :)

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).

Are there any special attributes that you need to apply (like OS guided resource management) that you need to support? Otherwise, for Unix you should be able to daemonize your application by writing an appropriate init.d script and setting your app to start automatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!