首页 > 学院 > 开发设计 > 正文

用java实现外部调用exe文件

2019-11-18 13:39:39
字体:
来源:转载
供稿:网友

  1.0 用java调用windows系统的exe文件,比如notepad,calc之类:
public class Demo{
public static void main(String args[]){
Runtime rn=Runtime.getRuntime();
PRocess p=null;

try{
p=rn.exec(notepad);
}catch(Exception e){
System.out.println("Error exec notepad");
}
}
}
2.0调用其他的可执行文件,例如:自己制作的exe,或是下载安装的软件
public class Demo{
public static void main(String args[]){
Runtime rn=Runtime.getRuntime();
Process p=null;

try{
p=rn.exec("/"D:/AnyQ/AnyQ.exe/"");
}catch(Exception e){
System.out.println("Error exec AnyQ");
}
}
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表