How to start Java program as a daemon using Jsvc

3.9k views Asked by At

I am using Jsvc to start a java program that implements the Daemon interface. However when I issue the command

/usr/bin/jsvc -user walikha -home $JAVE_HOME -outfile out.file -errfile '$1'   Jooist.Server.jar Main

However the command silently executes and displays the prompt. How can I detect if the daemon is running? In the Java executable the init, start, stop and destroy functions just print to a log file using Log4J. The log file is not created and there is absolutely no indication that the service is running. Am I missing something, or have I left out something when configuring and installing Jsvc?

3

There are 3 answers

1
Dheeraj Joshi On

You can start a service as daemon by adding your application in /etc/init.d/ start/stop scripts.

1
Chander Shivdasani On

Modify your command to include options "-outfile" and "-errfile" and provide your own path to the log files.

/usr/bin/jsvc -outfile app.out -errfile app.err -user walikha -home $JAVE_HOME -outfile out.file -errfile '$1'   Jooist.Server.jar Main
0
Muhammad Gelbana On

Try the -debug switch and see what's going on. However, it looks like you've missed including commons-daemon-1.0.10.jar in your classpath.