I'm trying to use JSVC to run a java program as a daemon. This is the simple code that I have used:
package daemonexample;
public class DaemonExample implements Daemon {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
@Override
public void init(DaemonContext dc) throws DaemonInitException, Exception {
System.out.println("initializing ...");
}
@Override
public void start() throws Exception {
System.out.println("starting ...");
}
@Override
public void stop() throws Exception {
System.out.println("stopping ...");
}
@Override
public void destroy() {
System.out.println("done.");
}
}
And the command: jsvc -debug -home $JAVA_HOME -cp /path/to/commons-daemon.jar:/path/to/DaemonExample.jar -user coder -outfile /tmp/example.out -errfile /tmp/example.err -pidfile /tmp/example.pid daemonexample.DaemonExample
When I run this, I get: "redirecting stdout to /tmp/example.out and stderr to /tmp/example.err". But the target files are empty. What am I missing here?