I am searching for a .class file inside a bunch of jars.
jar tf abc.jar
works for one file. I tried
find -name "*.jar" | xargs jar tf
prints nothing. The only solution I can think of, is unzip all, then search. Is there a better way? I'm on LUnix.
Edit: When scanning many jars, it is useful to print the jar file name along with the class. This method works well:
find . | grep jar$ | while read fname; do jar tf $fname | grep SchemaBuilder && echo $fname; done
Sample output produced:
1572 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder$1.class
1718 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder$2.class
42607 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder.class
./XmlSchema-1.3.2.jar
1572 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder$1.class
1718 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder$2.class
42607 Wed Jul 25 10:20:18 EDT 2007 org/apache/ws/commons/schema/SchemaBuilder.class
./XmlSchema.jar