When executing some command(let\'s say \'x\') from cmd line, I get the following message: \"....Press any key to continue . . .\". So it waits for user input to unblock.
I think the recommended ray of executing external applications in Java is using a ProcessBuilder. The code looks like
//Launch the program
ArrayList command = new ArrayList();
command.add(_program);
command.add(param1);
...
command.add(param1);
ProcessBuilder builder = new ProcessBuilder(command);
//Redirect error stream to output stream
builder.redirectErrorStream(true);
Process process = null;
BufferedReader br = null;
try{
process = builder.start();
InputStream is = process.getInputStream();
br = new BufferedReader( new InputStreamReader(is));
String line;
while ((line = br.readLine()) != null) {
log.add(line);
}
}catch (IOException e){
e.printStackTrace();
}finally{
try{
br.close();
}catch (IOException e){
e.printStackTrace();
}
}
The process object has a get[Input/Output/Error]Stream that could be used to interact with the program.