Monday, August 8, 2011

Call an Exe

Call an exe file with parameters from Java.

import java.io.IOException;

public class RunAnExe {

public static void main(String[] args) {

Runtime rt = Runtime.getRuntime();
Process p =null;
try {
p = rt.exec("notepad c:/test.xml");
} catch (IOException e) {
System.out.println("Exe does not exist or access rights issues" + e.getMessage());
}
System.out.println("Process Exit Normally" + p.exitValue());
}
}

No comments:

Post a Comment