How to search for a string in JAR files

后端 未结 10 1116
小蘑菇
小蘑菇 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:33

    Although there are ways of doing it using a decomplier or eclipse , but it gets tricky when those jars are not part of your project , or its particularly painful when using decompiler and you have 100s or 1000s of jars placed in several folders.

    I found this CMD command useful , which helps in finding the class names in list of jars present in directory .

    forfiles /S /M *.jar /C "cmd /c jar -tvf @file | findstr "classname" && echo @path
    

    You can either navigate to your desired path , and open cmd from there and run this command OR give the path directly in command itself , like this

    forfiles /S /M *.jar /C "cmd /c jar -tvf @file | findstr /C:"classname" && echo @path
    

    My use case was to find a particular class in Glassfish , so command will look something like this :

提交回复
热议问题