java - How to use Apache Commons Daemon with Cross-Platform Service? -


i have java daemon (system service running 24/7/365) needs deploy executable jar, users (on windows, linux , mac alike) able start/stop application via:

service myapp start  service myapp stop 

(or whatever equivalent windows/mac services). obviously, requires @ os-level map myapp "service" particular method call inside java app (perhaps, lifecyclemanager#start() , lifecyclemanager#stop() respectively).

i heard apache commons daemon can used purpose, , after perusing site, looks this. looks it's old project , there isn't documentation accomplishing looking for.

so ask: can commons-daemon need, or need else or in addition? how can cross-platform daemon out of executable jar? in advance!

yes, apache commons daemon can run jar service on windows (using procrun) or daemon on *nix (using jsvc). used on windows, rest applies procrun:

procrun supports proper windows service shutdown (it can invoke stop method in running application). has little bit of functionality optionally redirecting stdout , stderr separate log files, , running service wrapper exe directly (assuming renamed service name) runs non-service mode console lets see output immediately. want use procrun's "jvm mode". read details of how in documentation.

if need additional fancier capabilities, such if service needs able restart itself, take @ yajsw (yet java service wrapper) instead. yajsw quite better overall, haven't tried yet.


Comments