tags:

views:

33

answers:

2

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?

A: 

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...;)

hvgotcodes
well that would be too simple :-) Let me rephrase my question with an example$ lsmyWarFile.war$ jar -tvf myWarFile.war | grep myJarFileWEB-INF/myJarFile.jarquestion is, how do I see the contents of myJarFile.jar "without first extracting the contents of myWarFile.war" .. is there a shortcut?
sunny8107
the 't' option means just show the contents, it does not actually extract the war.from the man page: t Lists the table of contents from jarfile (if f is specified) or standard input (if f and jarfile are omitted). If inputfiles is specified, only those specified files and directories are listed. Other- wise, all files and directories are listed.
hvgotcodes
aah i see. man i always read the question wrong. You have a jar file inside a war, and want to see the jar. In that case, extract only the jar from the war, then list the contents, then delete the extracted file...edited my answer above with all the steps...
hvgotcodes
yep..that works...i guess can't avoid extracting ;-) .. thanks anyways
sunny8107
A: 

I think your best shot is guessing, but that's not very reliable.

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

xor_eq