The Skoll Client retrieves a set of commands from the Skoll Server to compile and test MySQL; these commands are UNIX shell commands. My Google Summer of Code project is to work on the Java Skoll Client, I spent a great deal of time and effort getting these shell commands to run well in Java. Running shell commands in Java is not always straightforward, here are some techniques I learned to get the job done.
Use Java's ProcessBuilder class instead of Runtime class for Java 5.0+ projects. There are two reasons. First, ProcessBuilder has redirectErrorStream() method that automatically merges the standard output and standard error together so the output of a command would make more sense and more importantly the process won't freeze if the developer doesn't clear the error output stream. Second, the environment() method returns a nice Map the developer can use to manipulate the environment in which the command should run. Unfortunately, I must …
[Read more]