1

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?

Greg Kopff
16.7k14 gold badges57 silver badges80 bronze badges
asked Jun 5, 2012 at 3:43
6
  • 4
    What do you mean by 'complete new process'? The two API you mentioned create actual processes. Commented Jun 5, 2012 at 3:45
  • 1
    Runtime.exec and ProcessBuilder both do create complete new processes. Commented Jun 5, 2012 at 3:46
  • 1
    These 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. Commented 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"? Commented Jun 5, 2012 at 4:09
  • 1
    @GregKopff:You are right , i dont want my process to exit when JVM does. Commented Jun 5, 2012 at 4:13

2 Answers 2

1

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.

answered Jun 5, 2012 at 5:09
Sign up to request clarification or add additional context in comments.

Comments

0

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

answered Jun 5, 2012 at 5:00

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.