How to search for a string in JAR files

后端 未结 10 1115
小蘑菇
小蘑菇 2020-12-12 14:57

My application is built on Java EE.

I have approximately 50 jars in this application.

Is it possible to search for a particular keyword (actually I want to s

10条回答
  •  离开以前
    2020-12-12 15:45

    Caution: This is not an accurate answer, it's only a quick heuristic approach. If you need to find something like the name of a class (e.g., which jar has class Foo?) or maybe a method name, then this may work.

    grep --text 'your string' your.jar
    

    This will search the jar file as if it were text. This is quicker because it doesn't expand the archive, but that is also why it is less accurate. If you need to be exhaustive then this is not the approach you should use, but if you want to try something a little quicker before pulling out zipgrep this is a good approach.


    From man grep,

      -a, --text
              Process  a binary file as if it were text; this is equivalent
              to the --binary-files=text option.
    

提交回复
热议问题