Apache Commons logo Apache Commons Exec


How mature is it?

The code was ported from Apache Ant and extensively tested on various platforms. So there is no reason not to use it and it is very likely better than any home-grown library.


How do I create a complex command line using single and double quotes?

It is recommended to use CommandLine.addArgument() instead of CommandLine.parse(). Using CommandLine.parse() the implementation tries to figure out the correct quoting using your arguments and file names containing spaces. With CommandLine.addArgument() you can enable/disable quoting depending on your requirements. Having said that this is the recommended approach using Ant anyway.


Are child processes automatically killed?

This functionality is largely depend on the operating system - on Unix it works mostly and under Windows not at all (see Bug 4770092). In terms of stability and cross-platform support try to start your applications directly and avoid various wrapper scripts.


Does commons-exec support java-gcj?

Well - one out of 55 regression tests fails. The EnvironmentUtilTest.testGetProcEnvironment() test fails because it detects no environment variables for the current process but there must be one since we require JAVA_HOME to be set. Not sure if this is a plain bug in java-gcj-4.2.1 or requires a work around in commons-exec


Why is the regression test broken on my Unix box

Please check if the shell scripts under "./src/test/script" are executable - assuming that they are not executable the "testExecute*" and "testExecuteAsync*" test will fail. We try very hard to keep the executable bit but they have somehow the tendency to to be lost ...