We have requirement of creating a new process from Java. I know we can create new sub-processes by using ProcessBuilder and Runtime.exec but our requirement is to create a complete new process. In other words, we do not want to have the spawned process exit when the JVM does.
Does anyone have ideas how we can do this using Java API or a 3rd party framework?
-
4What do you mean by 'complete new process'? The two API you mentioned create actual processes.xiaofeng.li– xiaofeng.li2012年06月05日 03:45:17 +00:00Commented Jun 5, 2012 at 3:45
-
1Runtime.exec and ProcessBuilder both do create complete new processes.FThompson– FThompson2012年06月05日 03:46:44 +00:00Commented Jun 5, 2012 at 3:46
-
1These classes creates the subprocess of the process from where the ProcessBuilder.start() method is called .In this case owner of this subprocess is the parent process from which it is started.Amit Verma– Amit Verma2012年06月05日 04:08:32 +00:00Commented Jun 5, 2012 at 4:08
-
Presumably you won't want to process to exit when the JVM does? Or do you have other reasons for wanting it to be "detached"?Greg Kopff– Greg Kopff2012年06月05日 04:09:35 +00:00Commented Jun 5, 2012 at 4:09
-
1@GregKopff:You are right , i dont want my process to exit when JVM does.Amit Verma– Amit Verma2012年06月05日 04:13:55 +00:00Commented Jun 5, 2012 at 4:13
2 Answers 2
I've made a test java program which spawns another process. When java program exits, the spawned process is still alive. So what is the problem? Anyway, in case of trouble you always can spawn a shell (.bat) file and spawn your process from it.
Comments
Do not think that can be done independently without taking help from OS.However, there is a similar thread here which talks about the same.
How do I launch a completely independent process from a Java program
Comments
Explore related questions
See similar questions with these tags.