How to Daemonize a Java Program?

Rich Apodaca picture Rich Apodaca · Feb 10, 2009 · Viewed 97.8k times · Source

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?

Answer

Bahaa Zaid picture Bahaa Zaid · Feb 11, 2009

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