我在JSF應用程序中,我有一個.bat
,我想在點擊Command
按鈕時啓動,此腳本位於我的項目的webcontent目錄中。 動作的代碼是:在Web應用程序上啓動.bat
public String genererRapportTable() {
try {
ServletContext ctx = (ServletContext) FacesContext
.getCurrentInstance().getExternalContext().getContext();
String realPath = ctx.getRealPath("/");
String[] command = { "cmd.exe", "/C", "start", realPath + "Tools\\cmd.bat" };
Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
的路徑是否正確構建,但劇本沒有啓動!
調試屏幕:
這是我得到的輸出:
所以路徑是正確的,但劇本沒有啓動。當我把.bat
放在c:\Tools
上時,我使用這個路徑"C:\\Tools\\cmd.bat"
它可以工作。 問題是什麼?
是的是的,我使用過的啓動不跑,我只是試着運行測試! – Potinos 2012-07-18 11:06:08
的java -Xmx512m -jar schemaSpy_5.0.0.jar -t orathin -db nrefurg -host colline2 -port 1533 -s GA_ADM -u ga_adm -p ga_adm -o DOC -dp ojdbc-14.jar -i DOC -GV「Graphviz_2。 28「-hq – Potinos 2012-07-18 11:08:04
就像@jeb評論的那樣,你需要添加標題參數(第一個參數)。在命令提示符下檢查'start /?'並驗證語法。 – Cascader 2012-07-18 11:36:04