开发者

how to list the contents of a jar file inside a war file

Lets say I have a .war file

myWarFile.war

This file has a jar file inside it - WEB-INF/myJarFile.jar

I want t开发者_如何转开发o see what are the files inside myJarFile.jar without extracting the war file.

Is there a way to do it?


jar xvf thewar.war /path/to/jar/inside/war #extract the file...    
jar tvf /path/to/jar/indide/war.jar # read the extracted jar  
rm /path/to/jar/inside/war # remove it 

I just did this and it did not delete the file I extracted from the war. Please verify that though...;)


If you open the war in 7-zip you can open nested jars too.

I always use this script when I want to search or grep all the classes and other files on the classpath in a war (it does extract the war file though)

#!/bin/bash
#
# Unzips all the libs in a war
set -o errexit
set -o nounset
mkdir -p contents
cd contents
unzip $1
mkdir -p jars
cd jars
for jar in ../WEB-INF/lib/*.jar; do
  basejar=$(basename $jar)
  mkdir -p "$basejar"
  unzip -o "$jar" -d "$basejar"
done


A zipped archive (a .war is nothing else) contains a table of contents and packed files. There is no way of accessing the contents of any of the packed files without extracting them first.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜