Find class in jar unix script

less than 1 minute read

Unix script to search for a class or package name in a set of jars. Handy for debugging ClassNotFoundExceptions

<pre name="code" class="shell">
#!/bin/sh

JARDIR=$1
CLASS=$2
echo “Looking for class name $CLASS in directory $JARDIR”

for i in find $JARDIR -name "*jar"
do
echo “Looking in $i …“
jar tvf $i
grep $CLASS
done
</pre>

Create an alias

<pre name="code" class="shell">
alias findinjars=’~/poconnell/tools/scripts/findinjars.sh’
</pre>

Categories:

Updated:

Leave a Comment