Thursday, September 25, 2008

Search jar files for class

Heres a handy little command for searching classes withen jar files (for example when searching all the jars in a war file)

find <dirs> -name '*.jar' -exec jar tvf {} \; > outputfile

THis will produce a list of all files in the jar files outputted to outputfile.

This script below will print out the filename of each jar, and each associated file within.

list=$(find /apps/bea -print | grep .jar)

for el in $list; do

printf "Searching in %s\n" "$el";

case $el in

jar -tf $el | grep com.bea.console.utils.ConsoleRequestListener