在一个命令中提取几个jar

问题描述:

我有很多文件夹(20)的jar文件, 有没有一种方法可以在终端 中的一个命令中提取所有这些jar,而不是一个接一个地执行它? 我已经MAC在一个命令中提取几个jar

一个简单的solution.-获取所有的罐子和提取它

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

嗨,谢谢。即时通讯和错误,我应该在cli的根文件夹? –

+0

没有必要。你必须在同一个文件夹中,罐子可用。还有你得到什么错误? – nagendra547

+0

im在包含jar列表的文件夹中的终端并获取此错误java.io.FileNotFoundException :(无此文件或目录) at java.io.FileInputStream.open0(Native Method) –

你可以使用这个在所有的罐子的文件夹 -

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 –