find-a-jar-file-given-the-class-name
Save this as findclass.sh (or whatever), put it on your path and make it executable:
#!/bin/sh
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
The first parameter is the directory to search recursively and the second parameter is a regular expression (typically just a simple class name) to search for.
$ findclass.sh . WSSubject
The script relies on the -t option to the jar command (which lists the contents) and greps each table of contents, labelling any matches with the path of the JAR file in which it was found.
I have written a program for this: https://github.com/javalite/jar-explorer It will also decompile existing byte code to show you interfaces, methods, super classes, will show contents of other resources - text, images, html, etc.
There is no "official" Java way to do this AFAIK.
The way I usually hunt for it is to use find and jar to look through all jar files in a given tree.
> find . -name \*.jar -print -exec jar tf {} oracle/sql/BLOB.class \;
./v2.6.1/lib/csw_library.jar
./v2.6.1/lib/oracle_drivers_12_01.jar
oracle/sql/BLOB.class
If you're on Windows and don't want to install Cygwin, then I suppose you would have to write a batch script to locate the jar files.
If the grep on your system (e.g. Solaris) doesn't have -H and --label as used in Dan Dyer's example, you can use:
find . -name '*.jar' -type f | xargs -i bash -c "jar -tvf {}| tr / . | grep WSSubject && echo {}"
$ find . -iname *.jar | while read JARF; do jar tvf $JARF | grep Log.class && echo $JARF ; done
479 Fri Oct 10 18:19:40 PDT 2003 org/apache/commons/logging/Log.class
3714 Fri Oct 10 18:19:40 PDT 2003 org/apache/commons/logging/impl/Log4JCategoryLog.class
1963 Fri Oct 10 18:19:40 PDT 2003 org/apache/commons/logging/impl/NoOpLog.class
9065 Fri Oct 10 18:19:40 PDT 2003 org/apache/commons/logging/impl/SimpleLog.class
./WebContent/WEB-INF/lib/commons-logging.jar
In Windows, run cmd.exe and type:
for %i in (*.jar) do @jar tvf %i | find "/com/company/MyClass.class"
The jars would have to be in the current directory. For also has a /R option which takes a directory and lets you search recursively.
If Jar.exe isn't in your path, you can do something like @C:\jdk\bin\jar.exe.
You could try services like:
Or
- Google Desktop with the Airbear Software's IndexZip Plug-in
Or
- A maven enterprise repository with a search feature e.g. Nexus (OFC, this would only work if the jars you're looking for are indexed i.e. installed in the repository)
Printing the list as I go so I can see what I'm checking. Mostly I'm looking in a lib/app directory, but you can substitute a locate for the find.
e.g.
for jar in $(find some_dir/lib -name "*.jar" );
do
echo -------------$jar-------------------
jar -tf $jar | grep TheNameOfTheClassImLookingFor
done
http://stackoverflow.com/questions/1500141/find-a-jar-file-given-the-class-name
find-a-jar-file-given-the-class-name的更多相关文章
- eclipse 中的 jar file 和 runnable jar file的区别
转自于:http://blog.csdn.net/lijiecong/article/details/6266234 java最难学的就是角落的东东了,不愧叫做java平台.搜索了一把总算明白了. 直 ...
- eclipse下提交job时报错mapred.JobClient: No job jar file set. User classes may not be found.
错误信息: 11/10/14 13:52:07 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. A ...
- 现网环境业务不影响,但是tomcat启动一直有error日志,ERROR org.apache.catalina.startup.ContextConfig- Unable to process Jar entry [module-info.class] from Jar [jar:file:/home/iufs/apache-tomcat/webapps/iufs/WEB-INF/lib/asm
完整的错误日志信息: 2019-03-19 15:30:42,021 [main] INFO org.apache.catalina.core.StandardEngine- Starting Ser ...
- eclipse 运行 mapreduce程序报错 No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
报错信息 17/07/06 17:00:27 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Ap ...
- An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene50' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classp
背景介绍: 当ES中guava库与hive等组件的库冲突时,对Elasticsearch库进行shade,relocate解决库冲突问题. 当使用"org.apache.maven.plug ...
- org.apache.jasper.JasperException:Unable to read TLD "META-INF/c-1_0-rt.tld" from JAR file jstl-1.2.jar
前两天把项目从eclipse EE版搬到MyEclipse中了.配置好jdk,确定build path中没有报错后,在tomcat中运行.结果,报错: org.apache.jasper.Jasper ...
- Eclipse------使用Debug As时报错java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/XXX
报错信息: java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file ...
- Unable to read TLD "META-INF/c.tld" from JAR file
Unable to read TLD "META-INF/c.tld" from JAR file CreationTime--2018年7月18日17点46分 Author: ...
- Failed to read Class-Path attribute from manifest of jar file:/XXX问题
java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/XXX ...
- eclipse中jar file与runnable jar file的区别
直接运行 .class的方法 java -cp . com.network.Chat , 不用加.class后缀 从eclipse中export 的jar file,仅仅是把.class ...
随机推荐
- 1.unix网络编程基础知识
接触网络编程一年多了,最近在系统的学习vnp两本书,对基础知识做一些总结,希望理解的更透彻清晰,希望能有更多的沉淀. 1.套接口地址 针对IPv4和IPv6地址族,分别定义了两种类型的套接口地址:so ...
- 转:什么是 HTTP Headers?
什么是HTTP Headers HTTP是“Hypertext Transfer Protocol”的所写,整个万维网都在使用这种协议,几乎你在浏览器里看到的大部分内容都是通过http协议来传输的,比 ...
- perl 5.22手动安装Mysql DBI和DBD
mysql 手动安装DBI 和DBD: DBI版本: [root@dr-mysql01 DBD-mysql-4.033]# perl -MDBI -le 'print $DBI::VERSION;' ...
- Android的BUG(一) - HTML 5 播放streaming video造成卡住的问题
这个bug,是google自带的问题. 和见到的诸多android的疑难问题一样,这又是一个可以归类为 多线程同步/状态机 问题. 问题处在NuPlayer的异步消息的handle中,现象和原因不细说 ...
- Python学习-使用matplotlib画动态多图
最近常常使用matplotlib进行数学函数图的绘制,可是怎样使用matplotlib绘制动态图,以及绘制动态多图.直到今天才学会. 1.參考文字 首先感谢几篇文字的作者.帮我学会了怎样绘制.大家也能 ...
- 在Vista以上版本运行WTL程序,有时候会提示“这个程序可能安装补正确...”的错误
在Win7/Vista下,如何以兼容模式运行exe? https://msdn.microsoft.com/en-us/library/dd371711(VS.85).aspx 问题描 ...
- 04-UIKit(UINavigationController、NSAttributeString、UIImageView)
目录: 一.UINavigationController导航视图控制器 二.NSAttributeString属性字符串 三.UIImageView图像处理 回到顶部 一.UINavigationCo ...
- Arcgis镶嵌数据集java代码操作
转自:http://www.cdtarena.com/javapx/201307/9105.html 镶嵌数据集结合了之前arcgis管理影像的栅格目录和栅格数据集,为解决海量影像管理提供了很好的方案 ...
- powerMock比easyMock和Mockito更强大(转)
powerMock是基于easyMock或Mockito扩展出来的增强版本,所以powerMock分两种类型,如果你习惯于使用easyMock的,那你就下载基于easyMock的powerMock,反 ...
- 服务列表 - Sina App Engine
服务列表 - Sina App Engine 短信服务 新浪无线短信服务是由新浪无线提供的综合性短信服务. 使用服务 下载SDK: php 服务首页 方法 新浪无线短信服务是由新浪无线提供的综合性短信 ...