Obtain a ProcessExecutor from the ProcessExecutorFactory:
ProcessExecutor cli = ProcessExecutorFactory.getDefault();
Then launch an operating system command:
Future<Integer> result = cli.execute( ProcessStreams.DEFAULT, null, "/bin/ls -ali" );
The process is started asynchronously.
System.out.println( result.get() );
And you can cancel it like this:
result.cancel( true );
You can redirect stdin, stderr and stdout of running processes to any Java Input and Output sreams. To do so, just implement the ProcessStreams interface and pass it to the "execute" method of your ProcessExecutor.