Tuesday, March 15, 2011

To find which class contains a method in a given jar

Okay.. I vaguely remembered a method that existed somewhere that could do what I wanted but could not recall the class it was in, and all I had was the jar. So I wrote this:


#!/bin/bash
for i in `jar tvf $1 | grep class | awk '{print $8}' | sed -e "s/\//./g" | sed -e "s/\.class//g"`;
do
echo $i;
javap -classpath $1 $i | grep $2;
done

Enjoy!

No comments: