比如我要杀死phantomjs的进程
Properties props = System.getProperties();
String os=props.getProperty("os.name");//获取当前系统名称,win和linux的用法是不一样的if(os!=null){
os=os.toLowerCase();
if(os.contains("win")){
Runtime.getRuntime().exec("taskkill /F /IM phantomjs.exe");
}else{
Runtime.getRuntime().exec("pkill -f 'phantomjs'");
}
}