版权声明:本文为博主原创文章,转载须注明出处,博客地址:https://blog.csdn.net/wx13227855087 https://blog.csdn.net/wx13227855087/article/details/82781321
直接上代码,向下看:
package test;
import java.io.IOException;
/**
* java代码打开应用程序
* @author dellpc
*/
public class Open {
/*
* windows下路径的两种写法
* 1: path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"; 反斜杠‘\'需要转义成'\\’
* 2:path = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"; 不需要转义
*/
public static void main(String[] args) {
Runtime runtime = Runtime.getRuntime();
Process p = null;
String path ="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
try {
p = runtime.exec(path);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}