Best Practices from Oracle Development's A‑Team

Finding which JAR contains a class

Mark Nelson

I often want to search through a large number of JAR files looking for a particular class, and every time I do this I wish I had some utility to make it easier.  So I finally made one:

#!/bin/sh TARGET="$1" for i in `find . -name "*jar"` do   jar tvf $i | grep $TARGET > /dev/null   if [ $? == 0 ]   then     echo "$TARGET is in $i"   fi done

Update: My colleague Chris Johnson just posted a better version of this, with some caching over at the Fusion Security Blog.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha