❶ java怎麼調用shell腳本
//用法:Runtime.getRuntime().exec("命令");Stringshpath="/test/test.sh";//程序路徑Processprocess=null;Stringcommand1=「chmod777」+shpath;try{Runtime.getRuntime().exec(command1).waitFor();}catch(IOExceptione1){e1.printStackTrace();}catch(InterruptedExceptione){e.printStackTrace();}Stringvar="201102";/參數專Stringcommand2=「/bin/sh」+shpath+」」屬+var;Runtime.getRuntime().exec(command2).waitFor();