Using Java, can I have one JVM spawn another, and then have the original one exit?

Posted by CarlG on Stack Overflow See other posts from Stack Overflow or by CarlG
Published on 2010-06-09T20:20:28Z Indexed on 2010/06/09 20:22 UTC
Read the original article Hit count: 174

Filed under:
|

I have a need to have a running JVM start another JVM and then exit. I'm currently trying to do this via Runtime.getRuntime().exec(). The other JVM starts, but my original JVM won't exit until the "child" JVM process stops. It appears that using Runtime.getRuntime().exec() creates a parent-child relationship between the processes. Is there some way to de-couple the spawned process so that the parent can die, or some other mechanism to spawn a process without any relationship to the creating process?

Note that this seems exactly like this question: http://stackoverflow.com/questions/2566502/using-java-to-spawn-a-process-and-keep-it-running-after-parent-quits but the accepted answer there doesn't actually work, at least not on my system (Windows 7, Java 5 and 6). It seems that maybe this is a platform-dependent behavior. I'm looking for a platform independent way to reliably invoke the other process and let my original process die.

© Stack Overflow or respective owner

Related posts about java

Related posts about processes