通过ecec()执行exe文件,然后在后台发送控制台(.exe)



我想在后台运行指定的文件(.exes)。。。

File file = new File ("C:\Documents and Settings\INTEL\My Documents\NetBeansProjects\demo\calc.exe");  
Desktop.getDesktop().open(file);  

如果我使用运行时的东西

怎么办

在单独的进程中执行指定的字符串命令

Process process = Runtime.getRuntime().exec("C:\Documents and Settings\INTEL\My Documents\NetBeansProjects\demo\calc.exe");

您可以在另一个线程中执行您的进程

Thread thread = new Thread(){
  public void run(){
    try {
      Runtime.getRuntime().exec("...");
    } catch (Exception e) { ... }
  }
}
thread.start();

最新更新