Java Tip : How to locate class files in a jar jungle

This is one command that I find very useful at work. I learned it from my Collegue Manish.

If you have lot of jar files lying in some directories and you want to find which jar file contains Foo.class,

for i in `find . -name “*.jar”`; do echo $i; jar tvf $i | grep “Foo”; done

For Windows users, this might be a full day work, rite? Enjoy!

1 Comment »

  1. NewSingh said

    This is a good one for Solaris. Being a developer, anyone will need this pretty often.
    But don’t question the usability of Windows. It’s not a full day job.In fact it takes seconds using the standard Microsoft Search.
    Thanks anyway for the post. Now I am going to use this command instead of pulling the jar using FileZilla to Windows and then doing the search(in seconds) for the class file.

RSS feed for comments on this post · TrackBack URI

Leave a Comment