0
我試圖運行這個'gzip.bat'。它所做的就是壓縮它所在目錄中的所有文件。'gzip.exe'位於同一目錄中。'不被識別爲內部或外部命令'從Java運行批處理
@echo off
ren *.dat *.
gzip *.
pause
它運行得很好,當我從Windows資源管理器中運行它。
但是,當我試圖從Java運行它,我得到的錯誤:
The system cannot find the file specified.
'gzip' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
這裏是Java代碼我使用:
Runtime runtime = Runtime.getRuntime();
try {
Process p1 = runtime.exec("cmd /c start .\\data\\mapmaker\\gzipdir\\gzip.bat");
InputStream is = p1.getInputStream();
int i = 0;
while((i = is.read()) != -1) {
System.out.print((char)i);
}
} catch(IOException ioException) {
System.out.println(ioException.getMessage());
}
我在做什麼錯?
已經將其改爲 過程P1 =的Runtime.exec( 「CMD/C開始\」 M:\\工作區\\客戶端工具\\數據\\繪圖者\\ gzipdir \\ gzip.bat \ 「」 ); 它仍然不起作用。 – 2014-08-28 07:38:25