1 在windows平台上,java调用bat文件:
importjava.io.IOException;
/**
* 测试执行bat命令
* Created by andyzhao on 2017/4/10.
*/
public class WindowBatShellTest {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
try {
String file = "F:/aaa.bat";
rt.exec("cmd.exe /c " + file);//执行后关闭命令窗口
//rt.exec("cmd.exe /c start " + file);//加上start保持命令窗口
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
2 在linux平台上,java调用shell文件
