Simple example Java version 1.5
suggest changeThis example will call the Windows calculator. It’s important to notice that the exit code will vary according to the program or script that is being called.
package process.example;
import java.io.IOException;
public class App {
public static void main(String[] args) {
try {
// Executes windows calculator
Process p = Runtime.getRuntime().exec("calc.exe");
// Wait for process until it terminates
int exitCode = p.waitFor();
System.out.println(exitCode);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents