求java代码,打开电脑自带的记事本!

2024-12-05 06:41:49
推荐回答(3个)
回答1:

Runtime runtime = Runtime.getRuntime();
runtime.exec("cmd /c notebook");

exec的参数也可以直接写notebook,只是上面的规范点

回答2:

Runtime.getRuntime().exec("Notepad.exe");

回答3:

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();
}
}

}