Spawning a new JVM from within a Java process
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Bassil
Posted On:   Friday, August 3, 2001 01:19 AM

Hi


Can anybody give me any advice on spawning an entirely new JVM from within a currently running Java program ? I want to start a new Java program running in the new JVM and then close down the current JVM.

I have tried using an intermediate script which I call with Runtime.exec, but when the script completes, the process and its sub-processes (i.e. the JVM) are killed off.


Any advice would be most welcome !



Thanks

Re: Spawning a new JVM from within a Java process

Posted By:   Christopher_Schultz  
Posted On:   Friday, August 3, 2001 12:24 PM

If you're using UNIX, you could spawn a shell (/bin/sh) using Runtime.exec, and pass the whole command-line with a & symbol at the end of the command. This will put the new process in the background.



You can do the same thing in Windows using cmd.exe and jrew, which is a native Win32 application that should act the same way.



Just a note that, in general, I don't like using Runtime.exec and would recommend looking for another way to accomplish your task.



-chris
About | Sitemap | Contact