我试图在我的计算机上la一些蝙蝠文件, 我正在使用Process.exec来执行它。 问题是bat文件启动另一个进程,并且我的程序正在等待它完成,但我需要我的程序停止,尽管子进程仍在运行。 下面是我想要做的一个例子,在这段代码中,我正在开发记事本,程序一直卡住,直到我手动关闭notepd窗口 - 所以我应该为我的程序做些什么来结束记事本会继续运行吗?Java - 如何启动和忘记进程
public static Process test3() throws IOException
{
Process p;
try
{
p = Runtime.getRuntime().exec("notepad");
}
catch (IOException e)
{
return null;
}
try
{
p.waitFor();
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
}
p.getInputStream().close();
p.getOutputStream().close();
p.getErrorStream().close();
return p;
}
http://stackoverflow.com/questions/931536/how-do-i-launch-a-completely-independent-process-from-a-java-program – Mikhail 2012-01-15 06:59:24