Java tutorial
import java.io.InputStream; class Run2 { public static void main(String[] args) throws java.io.IOException { if (args.length != 1) { System.err.println("usage: java Run pathname"); return; } Process p = Runtime.getRuntime().exec(args[0]); InputStream is = p.getInputStream(); int b; while ((b = is.read()) != -1) System.out.print((char) b); try { System.out.println("Exit status = " + p.waitFor()); } catch (InterruptedException e) { } } }