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");
}
}
}
博客介绍了用Java调用Windows系统exe文件的方法。给出了调用系统自带的notepad、calc等exe文件的示例代码,还展示了调用自己制作或下载安装的其他可执行文件的代码,并对可能出现的异常进行了处理。
617

被折叠的 条评论
为什么被折叠?



