在java中执行exe文件,java执行exe文件,如下代码,只是启动exe
分享于 点击 47121 次 点评:39
在java中执行exe文件,java执行exe文件,如下代码,只是启动exe
如下代码,只是启动exe文件:
public class transferExe { public static void main(String[] args) { openWinExe(); openExe(); } //用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!"); } } //调用其他的可执行文件,例如:自己制作的exe,或是下载安装的软件. public static void openExe() { Runtime rn = Runtime.getRuntime(); Process p = null; try { p = rn.exec("\"D:/QQ2010.exe\""); } catch (Exception e) { System.out.println("Error exec!"); } }}
用户点评