Find for a class file in Linux that is present in JAR

I am trying to find a JAR file which contains my class using below command given in this link : Find a jar file given the class name?

find . -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} GenericClassLoader' \;

but I am getting error as : error in opening zip file
        at Method)

Please help me in understanding the command and also how solve this error. I am using bash shell.


There is something in your filesystem, which ends with *.jar but which isn't a valid archive. To debug this, add -print to the find command:

find . -name "*.jar" -print -exec ...

This will make find print the name of the file before it tries to execute the sh command.


  • find .: Find all files and folder in the current directory
  • -name "*.jar" whose name ends with .jar
  • -exec and execute the following command for each of them
  • sh -c Create a new shell and execute ...
  • jar -tf {} Test a JAR archive. This (also) prints a list of files in the archive find will replace the {} with the path of the archive it found
  • | pipe the result of jar -tf into ...
  • grep search the input for ...
  • -H Print the filename for each match
  • --label {} Since we're reading from stdin, grep should use {} (again replaced by find) as the filename
  • GenericClassLoader search for this string in the output of jar -tf

Need Your Help

Toggle all elements within a nested Bootstrap Accordion

javascript jquery twitter-bootstrap collapse

I have a lot of nested bootstrap collapsible elements on a page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.