Camilo Díaz Repka
Camilo Díaz Repka

Reputation: 4815

How do you figure out with Eclipse which JARs depend on which one?

I've trying to use Eclipse JDT AST parsing classes. After including the initial JAR, and sorting out a couple more dependencies, it is with 7+ JARs and I still having NoClassDefFoundError exceptions. This situation arises whenever I'm trying to test libraries with little or no documentation. Trial and error seems a very dumb (and annoying) approach to solve this problem.

Is there a way to automatically sort this out using Eclipse?


Update: Later I found that adding all the JARs you have, and using Ctrl-T (to view/locate types), lets you manually locate the JAR. That was the solution that Google provided so far. Is there a better way?

Upvotes: 3

Views: 10521

Answers (3)

VonC
VonC

Reputation: 1324258

If you refer to this SO question Finding unused jars used in an eclipse project, you also have:

ClassPathHelper, which can quickly focus on unresolved classes:

unresolved

It automatically identifies orphan jars, blocked (obscured) classes, and much more.

The only limit is dependencies that are not defined in classes, e.g. in dependency injection framework configuration files.

Upvotes: 5

jamesh
jamesh

Reputation: 20091

I have found setting up a workspace exclusively for browsing the eclipse source code incredibly useful. In this manner, you can use PDE tools like the Plug-in Spy, bundle dependency analysis, browsing the documentation, etc much like you would your own plugin projects. I found this article at Vogella a very useful guide.

If you know which bundle your desired class is you can generate the transitive closure of dependencies by creating a new OSGi launch configuration, with just the single bundle selected. By hitting the Add Required button, you can see all bundles necessary to use the one you're interested in.

Edit:

  • From your question it wasn't clear as to the environment you want to run the compiler in. If you're interested in an embeddable Java compiler to be run outside of an OSGi environment, may I suggest Janino.

Upvotes: 1

billjamesdev
billjamesdev

Reputation: 14642

You could use a dependency analyzer like: JarAnalyzer

This will parse a directory full of Jars and give you an XML output dependency map, for which there are several tools for displaying in either graphical or text form.

Upvotes: 0

Related Questions