// Example: start another process, in this case a web browser. // Uses classes java.lang.Runtime and java.lang.Process . // L. Allison, Comp. Sci. and SWE., Monash University, Australia 3168. // http://www.cs.monash.edu.au/~lloyd/tildeProgLang/Java/ public class Exec { public static void main(String argv[]) { Runtime rt = Runtime.getRuntime(); try{ System.out.println("starting process"); Process p = rt.exec("netscape index.html"); // starts a web browser // ^^^^ System.out.println("started process"); try{ System.out.println("waitFor = " + p.waitFor()); }// NB. blocks catch(Exception e) { System.out.println("waitFor exception "); } } catch(Exception e) { System.out.println("exec exception"); } System.out.println("done"); }//main }// L.Allison, Comp. Sci. and SWE., Monash University, Australia 3168 // http://www.cs.monash.edu.au/~lloyd/tildeProgLang/Java/