Reputation: 409
Lets say I have a .war file
myWarFile.war
This file has a jar file inside it - WEB-INF/myJarFile.jar
I want to see what are the files inside myJarFile.jar without extracting the war file.
Is there a way to do it?
Upvotes: 6
Views: 16968
Reputation: 4073
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.
Upvotes: 0
Reputation: 120198
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...;)
Upvotes: 7
Reputation: 32407
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
Upvotes: 1