This method invokes the runtime exec
process=Runtime.getRuntime().exec(cmd);
//process = new ProcessBuilder(cmd).start();
// start stream flusher to push output to parent streams and null.
StreamFlusher sfErr=new StreamFlusher(process.getErrorStream(), System.err, null);
sfErr.start();
// set flusher on stdout also, if not could stop with too much output
StreamFlusher sfOut=new StreamFlusher(process.getInputStream(), System.out);
sfOut.start();
try {
// must sleep for a couple of seconds, so if there is a jvm startup error,
//the parent process
//is around to catch and report it when the process in executed in verbose mode.
Thread.currentThread().sleep(5000);
//wait is not required for command like start database
//where the process does not return since start database
//spawn it's own process.
if (wait) {
process.waitFor();
}
}
catch (InterruptedException ie) {
}