ProcessBuilder builder = new ProcessBuilder(命令,参数,参数。。。);
Process process = builder.start();
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
可以从br中读取日志信息
根据ID杀掉进程
String os = System.getProperty("os.name");
try {
if (os != null && os.startsWith("Windows")){
for (int i = 0; i < pid.size(); i++) {
Runtime.getRuntime().exec("Taskkill /f /IM " + pid.get(i));
}
}else{
for (int i = 0; i < pid.size(); i++) {
System.out.println("关闭linux进程");
String[] cmd ={"sh","-c","kill -9 "+pid.get(i)};
Runtime.getRuntime().exec(cmd);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}