Java: Runtime.exec() only work thru console-Collection of common programming errors
A few tips:
Just because you couldn’t get it to work differently using ProcessBuilder doesn’t mean that you should give up and use Runtime.exec(). Runtime.exec() is somewhere between really difficult and impossible to use for anything non-trival. So use ProcessBuilder – you’ll be happy you did.
Use the ProcessBuilder constructor that takes a list, not the one that takes a String. The one that takes a string has exactly the same problems as Runtime.exec()
If possible, use a batch file for Windows, or a shell script for Linux, that does as much of the work for you as possible (setting paths, etc.). Once you’ve debugged that at the command-line, you’ll have a much easier time using it with ProcessBuilder.
Invoke your environment’s shell (e.g. cmd /e or /bin/bash, or what-have-you, and have the shell execute the batch file.
Don’t forget to read the output streams from the spawned process. If you don’t, the child process will very likely lock up.