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 :

java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:131)
        at java.util.zip.ZipFile.<init>(ZipFile.java:92)
        at sun.tools.jar.Main.list(Main.java:997)
        at sun.tools.jar.Main.run(Main.java:242)
        at sun.tools.jar.Main.main(Main.java:1167)

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

Answers


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.

Explanation:

  • 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

How can I use Cocoa's Accessibility API to detect that a window is brought to front?

cocoa accessibility-api

I'm using the Accessibility API to detect when a certain application opens windows, closes windows, when the windows are moved or resized, or made main and/or focused. However the client app seems to

Default.ctp and a totally different login page

css cakephp view

Within my default.ctp page I keep navigational and structural content applicable to the entire application. For example menu structures and a column based CSS. I would like to change my login page,