The following code can be shipped in Windows 2000. Sayhi.exe is any one of the execution programs.
Public static void main (string args []) {string s = null; // system command to run string cmd = "cmd /cc:/sayhi.exe"; // set the working directory for the OS Command Processor File Workdir = New file ("c: //"); try {processim (). EXEC (CMD, NULL, WORKDIR); INT i = p.waitfor (); if (i == 0) {BufferedReader stdinput = New BufferedReader (p.GetInputStream ())))); // read the output from the command while ((s = stdinput.readline ())! = null) {system.out.println (s);}} else {BufferedReader stdErr = new BufferedReader (new InputStreamReader (p.getErrorStream ())); // read the output from the command while (! (s = stdErr.readLine ()) = null) {System.out.println (s );}}} catch (exception e) {system.out.println (e);}}
There is also such a code.
Public class executecommand {public static void main (string [] args) throws exception {string [] cmd = {"sh", "- c", "clear"}; // String cmd = "clear"; runtime = runtime .getruntime (); rt.exec (cmd);}}