现在的代码是
try
{
Process child=Runtime.getRuntime().exec("cmd.exe /c start "+batFileName);
InputStream in=child.getInputStream();
int c=0;
while(c!=-1)
{
c=in.read();
}
in.close();
try
{
child.waitFor();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println(batFileName+" done");
}
catch (IOException e)
{
e.printStackTrace();
}一般情况下可以自动退出,可是某些时候,比如执行一个运行时间比较长的编译命令的时候,运行完不退出,即使后面的语句写了exit想强制退出也不执行。而从电脑上双击bat文件的时候却可以自动退出,是不是有什么特殊的命令呢,我看了一下cmd里的参数好像也没有特别的啊。谢谢诸位大拿了。
try
{
Process child=Runtime.getRuntime().exec("cmd.exe /c start "+batFileName);
InputStream in=child.getInputStream();
int c=0;
while(c!=-1)
{
c=in.read();
}
in.close();
try
{
child.waitFor();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println(batFileName+" done");
}
catch (IOException e)
{
e.printStackTrace();
}一般情况下可以自动退出,可是某些时候,比如执行一个运行时间比较长的编译命令的时候,运行完不退出,即使后面的语句写了exit想强制退出也不执行。而从电脑上双击bat文件的时候却可以自动退出,是不是有什么特殊的命令呢,我看了一下cmd里的参数好像也没有特别的啊。谢谢诸位大拿了。
退出的话不太可能我觉得,除非改JVM.
InputStream in=child.getInputStream();
int c=0;
while(c!=-1)
{
c=in.read();
}
in.close();