ProcessBuilder: Forwarding stdout and stderr of started processes without blocking the main thread

Use ProcessBuilder.inheritIO, it sets the source and destination for subprocess standard I/O to be the same as those of the current Java process. Process p = new ProcessBuilder().inheritIO().command(“command1”).start(); If Java 7 is not an option public static void main(String[] args) throws Exception { Process p = Runtime.getRuntime().exec(“cmd /c dir”); inheritIO(p.getInputStream(), System.out); inheritIO(p.getErrorStream(), System.err); } private … Read more