Here you can find the source of executeAndWait(String command)
private static void executeAndWait(String command) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; public class Main { private static void executeAndWait(String command) throws IOException { try {/*from w w w. j ava 2 s. c o m*/ Process proc = Runtime.getRuntime().exec(command); int returnCode = proc.waitFor(); if (returnCode != 0) { throw new IllegalStateException( "Could not execute " + command + ", process returned " + returnCode); } } catch (InterruptedException e) { throw new IllegalStateException("Could not create execute command " + command, e); } } }