Run my Java program as a deamon process (Linux + Java)


I have a java program, and I would like to run it as deamon prcoess,

This is what I mean: when I type "java myProgram" on the command line, the program should be running in the background, and the system will return to the command line for another command.
The java program only tereminte when the computer reboots.

Anyhelp will be appericiated.
Who is Participating?
huabinAuthor Commented:
can i do it without the wrapper? in just pure java code? thanks.
No. You can't really run a program in the background in Windows unless you run it as a service. This requires native code.

You can start a program using javaw.exe and then close the command window leaving the process running, but that's messy
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Ajay-SinghConnect With a Mentor Commented:
You can do the same thing by running a java process that starts the actual java program, as

while(true) {
    Process process = Runtime.getRuntime().exec(...);
    int code = process.waitFor();
objectsConnect With a Mentor Commented:
Just start it with javaw instead of java :)
in linux use:

java MyClass &
kaliyugkaarjunConnect With a Mentor Commented:
Chk this link

it is Java Daemon JSR 96 [JSR about developing cross platform daemons]

WebstormConnect With a Mentor Commented:
If you're using Windows :

start javaw App
All Courses

From novice to tech pro — start learning today.