package 常用类.RunTime; import java.io.IOException; /**Runtime:没有构造方法摘要,说明该类不可以创建对象,又发现 * 还有非静态方法,说明该类应该提供静态的放回该类对象的方法。而且只有一个,说明Runtime类使用了单例设计 * 模式设计的; * * * */ public class RunTimeDemo { public static void main(String[] args) throws InterruptedException { demo_1(); } public static void demo_1() throws InterruptedException { Runtime r1 = Runtime.getRuntime(); //execute 执行 xxx.exe try { //指定运行程序,需要执行路径 Process p1=r1.exec("F:\Notepad++\notepad++.exe D:\java\ThreadDemo1.java"); Thread.sleep(3000); p1.destroy(); } catch (IOException e) { e.printStackTrace(); } } }