Tools for finding all dependencies in Java jars

放肆的年华 提交于 2019-12-07 03:57:18

问题


Are there any tools that can be given a classpath or folder, and will search through all the .jar files looking for references to a particular class?

It would have saved me a day of searching in order to resolve this kind of problem.

In my case I had to find out where a rogue reference to a class was coming from, as it was stopping JBoss from starting correctly due to a NoClassDefFoundError. I suppose I am looking for this:

java -jar magicbullet.jar /path/to/search com.myproject.DodgyClass
Searching...
com.problematic.Otherclass in /path/to/search/dodgy.jar implements com.myproject.DodgyClass

Or similar. If not, I'll write one.


回答1:


Use Tattletale - http://www.jboss.org/tattletale. It helps you create an index which is very handy to search for classes etc.




回答2:


Under Linux (or Cygwin on Windows) you may use script from https://gist.github.com/980697.

Usage: findclass.sh <directory> <className>

Example: findclass.sh . ClassName (means "search for class named ClassName inside all jars/wars/ears/sars located within current directory and all its subdirectories")




回答3:


Google for "JarAnalyzer" a helpfull tool doing more exactly what you want (and a bit more ;D )



来源:https://stackoverflow.com/questions/6058062/tools-for-finding-all-dependencies-in-java-jars

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!