Return | Method | Summary |
---|---|---|
Process | exec(String command) | Executes the specified string command in a separate process. |
Process | exec(String[] cmdarray) | Executes the specified command and arguments in a separate process. |
Process | exec(String[] cmdarray, String[] envp) | Executes the specified command and arguments in a separate process with the specified environment. |
Process | exec(String[] cmdarray, String[] envp, File dir) | Executes the specified command and arguments in a separate process with the specified environment and working directory. |
Process | exec(String command, String[] envp) | Executes the specified string command in a separate process with the specified environment. |
Process | exec(String command, String[] envp, File dir) | Executes the specified string command in a separate process with the specified environment and working directory. |
import java.io.IOException;
public class Main {
public static void main(String[] args) {
Runtime runtime = Runtime.getRuntime();
try {
Process pro = runtime.exec("notepad.exe");
} catch (IOException e) {
e.printStackTrace();
}
}
}
Wait until notepad is terminated.
public class Main {
public static void main(String args[]) {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
p = r.exec("notepad");
p.waitFor();
} catch (Exception e) {
System.out.println("Error executing notepad.");
}
System.out.println("Notepad returned " + p.exitValue());
}
}
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |