如何在大量jar文件中找到特定的类名?
How would you find a particular class name inside lots of jar files?
(查找实际的类名,而不是引用它的类。)
(Looking for the actual class name, not the classes that reference it.)
推荐答案Unix
使用 jar (或 unzip -v ), grep 和 find 命令。
例如,以下内容将列出与给定名称匹配的所有类文件:
For example, the following will list all the class files that match a given name:
for i in *.jar; do jar -tvf "$i" | grep -Hsi ClassName && echo "$i"; done如果您知道要搜索的整个Java档案列表,可以将它们全部放入使用(符号)链接的同一目录。
If you know the entire list of Java archives you want to search, you could place them all in the same directory using (symbolic) links.
或使用查找(区分大小写)查找JAR文件包含给定的类名:
Or use find (case sensitively) to find the JAR file that contains a given class name:
find path/to/libs -name '*.jar' -exec grep -Hls ClassName {} \;例如,要查找包含 IdentityHashingStrategy :
$ find . -name "*.jar" -exec grep -Hsli IdentityHashingStrategy {} \; ./trove-3.0.3.jar如果JAR可能系统中的任何地方和 locate 命令可用:
If the JAR could be anywhere in the system and the locate command is available:
for i in $(locate "*.jar"); do echo $i; jar -tvf $i | grep -Hsi ClassName; doneWindows
打开命令提示符,切换到包含JAR文件的目录(或祖先目录),然后:
Windows
Open a command prompt, change to the directory (or ancestor directory) containing the JAR files, then:
for /R %G in (*.jar) do @jar -tvf "%G" | find "ClassName" > NUL && echo %G以下是它的工作原理:
网络
使用搜索引擎扫描 JAR文件。
更多推荐
在几十个JAR文件中找到一个类?
发布评论