I have a Java daemon (system service running 24/7/365) that needs to deploy as an executable JAR, however I would like users (on Windows, Linux and Mac alike) to be able to start/stop the application via:
service myapp start
service myapp stop
(Or whatever is the equivalent for Windows/Mac services). Obviously, this requires something at the OS-level to map the myapp
"service" to a particular method call from inside my Java app (perhaps, LifecycleManager#start()
and LifecycleManager#stop()
respectively).
I heard that Apache Commons Daemon can be used for this purpose, and after perusing their site, it looks like it does just this. However it looks like it's an old project and there really isn't any documentation for accomplishing what I am looking for.
So I ask: can commons-daemon
do what I need, or do I need something else or in addition? How can I get a cross-platform daemon out of an executable JAR? Thanks in advance!