Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search for java classes in a directory of jar files.

Status
Not open for further replies.

waded

Programmer
Apr 26, 2003
2
US
I want to find out which jar file contains a given class. I have many jar files in a directory to search. I tried:

find . -name '*.jar' -exec jar tvf {} \; | grep com.ibm.sslight

This returned the class files in the given package, but it did not return the name of the jar file the package was in.

How do I get the aboove command to also print the jar filename on the display along with the package names from the jar tvf output ?

Thanks
 


make the grep part of the -exec and add /dev/null as a second file to search. This will cause GREP to print out the name of the file being searched.


find . -name '*.jar' -exec jar tvf {} | grep com.ibm.sslight /dev/null \;


 
I tried:

find . -name '*.jar' -exec jar tvf {} | grep com.ibm.sslight /dev/null \;

This was the result:

bash-2.03$ find . -name '*.jar' -exec jar tvf {} | grep com.ibm.sslight /dev/null \;
find: incomplete statement
grep: can't open ;

I received this from another post, and it works:

find . -name '*.jar' -exec jar tvf {} \; -print | egrep '(com.ibm.sslight|.jar$)'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top