How can I visualize jar (not plugin) dependencies?

2019-01-17 08:23发布

问题:

I am currently refactoring a large Java application. I have split up one of the central (Eclipse) projects into about 30 individual "components", however they are still heavily inter-dependent. In order to get a better idea of what depends on what I am looking for some way to graph the compile time dependencies.

All tools I have found so far are capable of graphing package or class dependencies or the dependencies between Eclipse plugins, however what I have in mind should just take a look at the classpath settings for each Eclipse project and build a coarser grained graph from that.

Later I will then go deeper, however right now this would just mean I would not be able to see the forest for all of the trees.

回答1:

Structure101 is capable of visualizing class and method JAR level dependencies in Jboss 5.

See the screenshot below or view it larger.



回答2:

Check out JBoss Tattletale. It might not do all you ask but it's worth checking out. It's still relatively new though.

The tool will provide you with reports that can help you

  • Identify dependencies between JAR files
  • Find missing classes from the classpath
  • Spot if a class is located in multiple JAR files
  • Spot if the same JAR file is located in multiple locations
  • With a list of what each JAR file requires and provides
  • Verify the SerialVersionUID of a class
  • Find similar JAR files that have different version numbers
  • Find JAR files without a version number
  • Locate a class in a JAR file
  • Get the OSGi status of your project
  • Remove black listed API usage


回答3:

One tool that I believe would do what you want is Understand. It's not free, but you can download a free trial edition before investing any money into it.



回答4:

Take a look at Dependency Finder



回答5:

I am not sure if there is a(n Eclipse) classpath analysis tool.
May be Understand mentioned by MattK can help.

The closest I would pick amongst all the static code analysis tool referenced here would be JarAnalyzer (no graph though), able to detect "Physical dependencies" amongst jars.



回答6:

Sounds like a use case for Degraph. It analyzes a bunch of class files and jar's, and visualizes the dependencies.

What makes it suitable for your usecase (I think) is the possibility to define arbitrary groups of classes to be bundled together. So you can reproduce your jar structure, seeing dependencies, especially cyclic dependencies.

You can unfold the groups to see their contained classes or collapse them to simplify the view.

For a quick impression what is possible, take a look at the Degraph Examples.

Example for Log4j:



回答7:

JDeps is already included in the JDK, and shows JAR dependencies. For example:

jdeps -R -cp "my\jar\dir\*;my\other\jar\dir\*" my\classes\dir


回答8:

Check out Class Dependency Analyzer (CDA): http://www.dependency-analyzer.org/

I have found it very useful for tidying up jars.



回答9:

for the record (and for improving this knowledge base), I found Shrimp very helpful: http://www.thechiselgroup.org/shrimp

Also, for easy dependency-checking, Byecycle is worth a try, but seems not to be updated anymore: Byecycle

Both tools also offer Eclipse integration.