Ketan's Musings

Where he blogs about his eclipse musings

Finding a Class in a ton of jars

with 2 comments

This is how I do it. Create a script I call it findclass in some location on the path. /usr/local/bin is a good place, I prefer $HOME/bin. Remember to chmod this script to 755.

#!/bin/bash
find -iname "*.jar" | xargs -i unzip -l {} | less

In case you are new to less, here’s how you navigate:
1. To find a particular class say com.xyz.abc.MyClass, you type:

/com.xyz.abc.MyClass

2. To find what jar contains this class, you type:

?Archive:

Written by Ketan

July 26th, 2007 at 9:16 am

Posted in GNU & Linux,Java

Tagged with , , ,

2 Responses to 'Finding a Class in a ton of jars'

Subscribe to comments with RSS or TrackBack to 'Finding a Class in a ton of jars'.

  1. How’s this:

    find . -name “*.jar” | xargs -i unzip -l {} | grep -E “^Archive:|$1″ | less

    Example:

    > findclass Enclosed
    Archive: ./aspectj-1.5.3.jar
    Archive: ./aspectjweaver.jar
    Archive: ./junit.jar
    651 27-03-07 14:22 org/junit/runners/Enclosed.class

    Fewer things to navigate, easier to find the archives containing the matching classes.

    Josh G

    26 Jul 07 at 1:08 pm

  2. That’s an interesting way as well, actually :)

    Ketan

    26 Jul 07 at 1:29 pm

Leave a Reply

IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)

What is 11 + 3 ?
Please leave these two fields as-is: