Java tutorial
//package com.java2s; import java.io.IOException; public class Main { private static int exec(String cmd) { try { Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec(cmd); return p.waitFor(); } catch (IOException e) { e.printStackTrace(); return -1; } catch (InterruptedException e) { e.printStackTrace(); return -1; } } }