Starting External Programs Without the Pain

Today, I’ve found a nice description why Java’s RunTime.exec() method feels to clumsy. Since Java 5 there’s a major improvement – the ProcessBuilder class – but still, it could be done better. AdiGuba offers an library to do so (see Runtime.ecec() n’est pas de plus simple). If you’re able to read an article written in french, you will find a nice API.

A problem that hasn’t been solved by this API is that you can’t influence a process you didn’t start. Sometimes it happens that your Java applications starts an external process, crashing before the external process stops. You can restart your Java application, but it cannot kill the process its predecessor called into life. If you want to to things like that, you have to use JNI and to do some native C coding.