jargrep


This is a simple Perl script that will search through a directory full of Java ARchive (JAR) files for a given classname. It doesn't support wildcards or fully qualified classnames. By default it searches the current directory. It's useful when you have a directory full of JARs which is expected to contain a certain Java class somewhere. Usually, one of three things happens.

  1. The class is found in one of the files. This is often the expected behavior.
  2. The class is found in none of the files. This is expected if you are attempting to diagnose a NoClassDefinitionFoundException.
  3. The class is found in two places. This is rarely expected. But it can explain why you change your class but don't see any change during runtime. There is an older version of your class in a JAR being read ahead of the one you are changing.

It's usually best to place jargrep.pl somewhere in your classpath. Then you can invoke it with

  perl -S jargrep.pl classname
where classname is the name of your class. The -S flag will instruct the Perl interpreter to search your OS's PATH variable for the jargrep.pl. Once found, each JAR in the current directory will be inspected for a classname (no package prefix).

Download

jargrep.pl - The .txt extension is added to pacify some browsers out there. It's just a Perl script (text file).