 <p>Don't pass a <code>ByteArrayOutputStream</code> to the <code>PumpStreamHandler</code>, use an implementation of the abstract class <code>org.apache.commons.exec.LogOutputStream</code>. Something like this:</p> <pre class="lang-java prettyprint-override"><code>import java.util.LinkedList; import java.util.List; import org.apache.commons.exec.LogOutputStream; public class CollectingLogOutputStream extends LogOutputStream { private final List&lt;String&gt; lines = new LinkedList&lt;String&gt;(); @Override protected void processLine(String line, int level) { lines.add(line); } public List&lt;String&gt; getLines() { return lines; } } </code></pre> <p>Then after the blocking call to <code>exec.execute</code> your <code>getLines()</code> will have the standard out and standard error you are looking for. The <code>ExecutionResultHandler</code> is optional from the perspective of just executing the process, and collecting all the stdOut/stdErr into a list of lines.</p>