I suggest that you use the Process Builder class for that. It is much more robust. The Java API has one example.
There are many, many other examples on the web. Just search for 'java processbuilder example'.
One area you need to watch out for is to be sure to handle ALL of the streams (e.g. error) or a program that writes to that stream can block the app if you don't read the stream contents.