Tuesday, September 4, 2007

Search java class files in jars.

This script helps you find the jar file which contains specified java class file.

Usage is simple :

./findClass /home/ilkinulas/lib javax.xml.ws.WebFault

This command searchs all the jars in directory /home/ilkinulas/lib and lists the jars that contain javax.xml.ws.WebFault java class.

#!/bin/bash

START_DIR=$1;
KEYWORD=$2;

for i in `find $START_DIR -name *.jar`
do
(jar tf $i | grep -q $KEYWORD) && echo $i;
done

1 comments:

Anonymous said...

that will not work for nested classes :)