// A Runtime object has methods for dealing with the OS
Runtime r = Runtime.getRuntime();
// A process object tracks one external running process
Process p;
try {
// file contains unsorted data
p = r.exec("sort sortdemo.txt");
p.waitFor();
} catch (java.io.IOException e) {
System.err.println("I/O error: " + e);
} catch (InterruptedException e) {
// nothing to do
}