Runtime runtime = Runtime.getRuntime();
runtime.exec("cmd /c notebook");
exec的参数也可以直接写notebook,只是上面的规范点
Runtime.getRuntime().exec("Notepad.exe");
import java.io.IOException;
public class CMD {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
String command = "Notepad";
try {
rt.exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
}