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

Hi,

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.
huabinAsked:
Who is Participating?
 
huabinAuthor Commented:
can i do it without the wrapper? in just pure java code? thanks.
0
 
CEHJCommented:
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
0
The new generation of project management tools

With monday.com’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();
}
0
 
objectsConnect With a Mentor Commented:
Just start it with javaw instead of java :)
0
 
objectsCommented:
in linux use:

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

http://www.jcp.org/en/jsr/detail?id=96

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

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

start javaw App
0
All Courses

From novice to tech pro — start learning today.