jar -tvf hello.war
However, my .war
also contains some .jar
in a lib
folder within the .war
.
I need a command display the contents of all the .jar
s within the .war
.
The开发者_开发百科 reason I need command line and not use tools like Winrar is because I need to incorporate it in my UNIX shell script.
You can do this with a short script.
TEMPDIR=`mktemp -d`
REALPATH=`pwd`/$1
(cd $TEMPDIR && jar xf $REALPATH)
for j in `find $TEMPDIR -name "*.jar"`; do echo `basename $j`; jar tvf $j; done
rm -rf $TEMPDIR
E.G.
$ ./go.sh x.war
z.jar
0 Sat Jul 30 21:53:20 EST 2011 META-INF/
71 Sat Jul 30 21:53:20 EST 2011 META-INF/MANIFEST.MF
182 Sat Jul 30 21:52:54 EST 2011 go.sh
25 Sat Jul 30 21:50:46 EST 2011 zz.sh
x.jar
0 Sat Jul 30 21:33:28 EST 2011 META-INF/
71 Sat Jul 30 21:33:28 EST 2011 META-INF/MANIFEST.MF
0 Sat Jul 30 21:33:20 EST 2011 x
Not really useful in a shell script, but the easiest way I've found to do this when looking at webapps interactively is to open them in emacs; archive mode understands jars, and just needs to be told about .wars, by adding
(add-to-list 'auto-mode-alist '("\\.war\\'" . archive-mode))
to your .emacs
. Then you can open the war like a normal directory, plus anything insde it:
精彩评论