import java.io.*;
public class CmdExec {
public CmdExec(String cmdline) {
try {
String line;
Process p = Runtime.getRuntime().exec(cmdline);
// jdk1.0.2
DataInputStream input =
new DataInputStream(p.getInputStream());
// jdk1.1.1
// BufferedReader commandResult =
// new BufferedReader
// (new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
}
catch (Exception err) {
System.out.println("EXEC failed: " + err.toString());
err.printStackTrace();
}
}
public static void main(String argv[]) {
/*
** javac CmdExec myapp.exe
** javac CmdExec "myapp.exe /a"
*/
new CmdExec(argv[0]);
}
}