I want to launch a process from Java, read its output, and get its return code. But while it\'s executing, I want to be able to cancel it. I start out by launching the proce
I recommend checking out Apache Commons Exec to avoid recreating the wheel. It has some nice features like choosing between synchronous vs. asynchronous execution, as well as a standard solution to spawning a watchdog process that can help in timing out the execution in case it gets stuck.