This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Running the process even after the program quits! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Running the process even after the program quits!" Watch "Running the process even after the program quits!" New topic
Author

Running the process even after the program quits!

prashant pachouri
Greenhorn

Joined: May 27, 2001
Posts: 12
Hi guys!
I am facing a real life trouble here..
from my program I want to initiate some processes which should continue even after my program which started them goes off
In short,
I want to achieve something like this
public class Launcher{
main(){
Runtime.getRuntime().exec("java -cp cpofMyClasspFile MySocketServerClass");
}
}
now when I do a ^c on the command prompt to terminate the Launcher My socket server program also goes off can I achieve it some way.. I thought this has got something to do with daemon threads
Thanks a lot!
pach

------------------
If you are not living on the edge, you are wasting Space.


If you are not living on the edge, you are wasting Space.
Yuri Gadow
Greenhorn

Joined: May 08, 2001
Posts: 28
This is going to be OS dependant. I don't know how to accomplish this under windows without using a service, in *nix you'll be looking a variety of options. Suffice it to say, you're going to be depending on the tools provided by the OS to do background processes.
Daemon threads are related to VM shutdown only in that they do not prevent it. In other words, a VM will exit even if there are threads set daemon currently running, where normally it would not if a non-daemon thread was alive. When the VM shuts down, the threads go as well, daemon or otherwise.
prashant pachouri
Greenhorn

Joined: May 27, 2001
Posts: 12
Thanks Yuri,

Could you give me some I Idea on how to achieve this on unix.
Michelle Baxter
Greenhorn

Joined: Jan 22, 2001
Posts: 11
I haven't tried this, but to run a UNIX command from a window and have it continue after logging out or killing the window, try the nohup command. You should be able to do a man on it, or type nohup --help. Let me know if it works.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Running the process even after the program quits!
 
Similar Threads
executing class without main()
Desktop icon on NT4, Win98SE, XP, etc
Ubuntu 11.04
How to create sub applications
Securing Java code.