【发布时间】:2012-02-07 15:18:54
【问题描述】:
【问题讨论】:
-
欢迎来到 Stack Overflow。在提出新问题之前,请使用搜索(或谷歌);许多人已经被问到并得到了回答。
-
看看
Runtime.exec,如图here。
标签: java
【问题讨论】:
Runtime.exec,如图here。
标签: java
你可以使用下面的代码.........
Runtime rt = Rintime.getRuntime() ;
Process p => rt.exec("Program.exe") ;
【讨论】:
使用此代码
try
{
Runtime r = Runtime.getRuntime();
Process p2 = r.exec("a.exe"); //absolute or relative path
}
catch(IOExeption ex)
{
System.out.println(ex.getMessage());
}
【讨论】:
如果您有权限,您可以使用以下命令运行操作系统的命令:
String cmd = "c:/full/path/to/myCommand.exe";
Runtime run = Runtime.getRuntime();
Process pr = run.exec(cmd);
【讨论】:
import java.io.IOException;
public class ExeRunner
{
public static void main(String args[]) throws IOException
{
ProcessBuilder proc = new ProcessBuilder("<your_exe>", "exe_args");
proc.start();
}
}
【讨论】: