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?

Improve company productivity with a Business Account.Sign Up

x
 
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.