javaprocessapache-commons-exec

Deciding between Apache Commons exec or ProcessBuilder


I am trying to decide as to whether to use ProcessBuilder or Commons exec,

My requirements are that I am simply trying to create a daemon process whose stdout/stdin/stderr I do not care about. In addition I want to execute a kill to destroy this process when the time comes.

I am using Java on Linux.

I know that both have their pains and pitfalls (such as being sure to use separate thread to swallow streams can lead to blocking or deadlocks, and closing the streams so not to leave open files hanging around) and wanted to know if anyone had suggestions one way or the other as well as any good resources to follow.


Solution

  • commons-exec is not the best library I've ever used but it does solve the biggest pitfall in Java process invocation which is handling/consuming stdout/sterr properly.

    I've used ProcessBuilder in the past, which is fine, and commons-exec now which is also fine and handles most of the common cases easily.