Java – How to Daemonize a Java Program


I have a Java program that I'd like to daemonize on a linux system. In other words, I want to start running it in a shell and have it continue running after I've logged out. I also want to be able to stop the program cleanly.

I found this article which uses a combination of shell scripting and Java code to do the trick. It looks good, but I'd like something simpler, if possible.

What's your preferred method to daemonize a Java program on a Linux system?

Best Solution

Apache Commons Daemon will run your Java program as Linux daemon or WinNT Service.