两种方法可以打开本地程序:
public class Open {
public static void main(String[] args) throws Exception {
//打开本地程序文件方式1
Runtime rt = Runtime.getRuntime();
String fileLac = "D:\\HBuilder\\HBuilder.exe";
rt.exec(fileLac);
//打开本地程序文件方式2
Desktop desktop = Desktop.getDesktop();
File file = new File("C:/Windows/System32\cmd.exe");
desktop.open(file);
//打开本地网站,默认浏览器打开
URI uriNet = new URI("www.baidu.com");
Desktop.getDesktop().browse(uriNet);
}
}
三个是独立的小程序,运行一个注释掉其他两个