JAVA调用exe可执行文件
www.diybl.com 时间 : 2008-06-20 作者:佚名 编辑:本站 点击: [ 评论 ]
public class transferExe {
/**
* @param args
*/
public static void main(String[] args) {
openWinExe();
openMyExe();
}
// 用Java调用windows系统的exe文件,比如notepad,calc之类
public static void openWinExe() {
Runtime rn = Runtime.getRuntime();
Process p = null;
try {
String command = "notepad";
p = rn.exec(command);
} catch (Exception e) {
System.out.println("Error win exec ");
}
}
// 2.0调用其他的可执行文件,例如:自己制作的exe,或是下载安装的软件
public static void openMyExe() {
Runtime rn = Runtime.getRuntime();
Process p = null;
try {
p = rn.exec("\"E:/QQ2008Spring.exe\"");
} catch (Exception e) {
System.out.println("Error my exec ");
}
}
}