RunTimeクラス、プログラムを自動的に開き、プログラムを閉じる

508 ワード


public class T1 {
public static void main(String[] args) {

Runtime runtime = Runtime.getRuntime();
Process process=null;

try {
process= runtime.exec("notepad.exe");// ,
} catch (IOException e) {
e.printStackTrace();
}
try {
Thread.sleep(3000);//3
} catch (InterruptedException e) {
e.printStackTrace();
}
process.destroy();//
}
}