...
Note that if the streams are not merged (as shown in the next compliant solution), they must be drained concurrently. Failure to do this can cause the program to block indefinitely.
Compliant Solution (3) (Windows)
This complint solution (based on the Sun forums query Runtime.exec hangs even If I drain output), uses the ProcessBuilder
to merge the error and output streams to simplify the handling mechanism. The readToPrompt()
method interacts with the command prompt and reads the output of the invoked process.
...