You need to start a new thread, which will read the terminal output stream and copy it to the console after calling process.waitFor() .
Do something like:
String line; Process p = Runtime.getRuntime().exec(...); BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close();
The best approach would be to use the ProcessBuilder class and try writing something like:
ProcessBuilder builder = new ProcessBuilder("/bin/bash"); builder.redirectInput(); Process process = builder.start(); while ((line = reader.readLine ()) != null) { System.out.println ("Stdout: " + line); }
source share