AFAIK, one can run a command line executable from Java using Runtime. And even get error code with processes WaitFor(). But how can I read executables output? Both stdout and stderr?
1 Answer
Runtime tr = Runtime.getRuntime();
try {
Process p = tr.exec("c:\\a.bat");
InputStream err = p.getErrorStream();
InputStream std = p.getInputStream();
//TODO here we go!
} catch (IOException e) {
e.printStackTrace();
}
1 Comment
Jim Garrison
This does not work. The correct solution uses at least one more thread, two is better, to handle the asynchronous nature of co-processes.