2017-08-31 51 views
0

我有很多文件夾(20)的jar文件, 有沒有一種方法可以在終端 中的一個命令中提取所有這些jar,而不是一個接一個地執行它? 我已經MAC在一個命令中提取幾個jar

回答

1

一個簡單的solution.-獲取所有的罐子和提取它

find ./ -name "*.jar" -exec jar -xf {} \; 
+0

嗨,謝謝。即時通訊和錯誤,我應該在cli的根文件夾? –

+0

沒有必要。你必須在同一個文件夾中,罐子可用。還有你得到什麼錯誤? – nagendra547

+0

im在包含jar列表的文件夾中的終端並獲取此錯誤java.io.FileNotFoundException :(無此文件或目錄) at java.io.FileInputStream.open0(Native Method) –

1

你可以使用這個在所有的罐子的文件夾 -

jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] 

選項:

-c create new archive 

-t list table of contents for archive 

-x extract named (or all) files from archive 

-u update existing archive 

-v generate verbose output on standard output 

-f specify archive file name 

-m include manifest information from specified manifest file 

-0 store only; use no ZIP compression 

-M do not create a manifest file for the entries 

-i generate index information for the specified jar files 

-C change to the specified directory and include the following file 

請參考說明文檔以解釋 - http://docs.oracle.com/javase/tutorial/deployment/jar/unpack.html

您可以將用戶的* .jar到位JAR文件的提取所有

這應該在同一位置的罐子都存在提取。

jar xvf *.jar 
+0

我應該在[archived-file(s)]中放什麼? –

+0

其可選參數。 文檔狀態 - 歸檔文件是一個可選參數,由從歸檔文件中提取的文件的空格分隔列表組成。如果此參數不存在,則Jar工具將提取存檔中的所有文件。 –

+0

它工作了嗎? @RaynD –