/** A test of the Exec class. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * http://www.corewebprogramming.com/. * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class ExecTest { public static void main(String[] args) { // Note: no trailing "&" -- special shell chars not // understood, since no shell started. Besides, exec // doesn’t wait, so the program continues along even // before Netscape pops up. Exec.exec("/usr/local/bin/netscape"); // Run commands, printing results. Exec.execPrint("/usr/bin/ls"); Exec.execPrint("/usr/bin/cat Test.java"); // Don’t print results, but wait until this finishes. Exec.execWait("/usr/java1.3/bin/javac Test.java"); // Now Test.class should exist. Exec.execPrint("/usr/bin/ls"); } }