I am writing a Java application that needs to use an external command line application using the Apache Commons Exec library. The application I need to run has a fairly lon
For my purposes, it turns out I only needed to override the "ExecuteStreamHandler". Here is my solution, which captures stderr into a StringBuilder, and allows you to stream things to stdin and receive things from stdout:
class SendReceiveStreamHandler implements ExecuteStreamHandler
You can see the whole class as a gist on GitHub here.