tags:

views:

58

answers:

1

Hello,

I have a simple script that writes output to the console using ProcessBuilder. And OutputStreamWriter see:

http://stackoverflow.com/questions/3643939/java-process-with-input-output-stream

An earlier thread. I believe my problem rests with the fact a sub process is spawned and the initial Parent process is killed. Resulting in the OutputStreamWriter to throw a java.io.IOException: Broken pipe exception. Given the application is spawning a second process how can I connect my OutputStreamWriter to this new process? Including being able to read back the output it is generating? Is this even possible in Java? Surly java should be able to follow onto the spawned process.

Thanks

+1  A: 

Are you calling waitFor() on the process you are running? That should ensure you're parent doesn't complete before the child. You may also want to look at commons exec, which is an open source library designed to make your life easier when running separate processes in Java.

Jon Freedman