Solved

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

Posted on 2006-07-05
10
248 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:huabin
10 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 17044580
0
 

Author Comment

by:huabin
ID: 17044611
can i do it without the wrapper? in just pure java code? thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17044637
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 23

Assisted Solution

by:Ajay-Singh
Ajay-Singh earned 100 total points
ID: 17045281
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
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 17047156
Just start it with javaw instead of java :)
0
 
LVL 92

Expert Comment

by:objects
ID: 17047158
in linux use:

java MyClass &
0
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 100 total points
ID: 17048369
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
 
LVL 13

Assisted Solution

by:Webstorm
Webstorm earned 100 total points
ID: 17049248
If you're using Windows :

start javaw App
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question