如何在大量jar文件中找到特定的类名?
(查找实际的类名,而不是引用它的类。)
如何在大量jar文件中找到特定的类名?
(查找实际的类名,而不是引用它的类。)
当前回答
下面的脚本将帮助您
for file in *.jar
do
# do something on "$file"
echo "$file"
/usr/local/jdk/bin/jar -tvf "$file" | grep '$CLASSNAME'
done
其他回答
你可以在一个充满jar的目录中找到一个类,它带有一些shell:
寻找类“FooBar”:
LIB_DIR=/some/dir/full/of/jarfiles
for jarfile in $(find $LIBDIR -name "*.jar"); do
echo "--------$jarfile---------------"
jar -tvf $jarfile | grep FooBar
done
不知道为什么这里的脚本从来都不适合我。如此:
#!/bin/bash
for i in *.jar; do jar -tf "$i" | grep $1 | xargs -I{} echo -e "$i : {}" ; done
查找匹配给定字符串的jar:
找到。name \*.jar -exec grep -l YOUR_CLASSNAME {} \;
检查这个eclipse插件,它可以做你正在寻找的工作。
https://marketplace.eclipse.org/content/jarchiveexplorer
你可以使用locate和grep:
locate jar | xargs grep 'my.class'
确保在使用locate之前运行updatedb。