TJ-
TJ-

Reputation: 14373

Determining which jar did the .class come from in Eclipse IDE

I was debugging a certain thing in a maven project in Eclipse IDE. As usual when I stepped into (F5) a line, I reached a java class/file Persistence.class. I want to determine which jar did it come from.

The reason : There are two projects (existing) which have certain dependencies configured in pom.xml. I see two different source codes for the file - one of them gives the desired result while the other does not. I have tried looking for persistence-api, ejb etc. but didn't find any of them in the Maven dependencies shown in eclipse.

Hence, I want to grep the poms (of parent projects) to look for the jar.

To Summarize, Is there a view in Eclipse where I can see which jar a .class file is coming from?

Upvotes: 3

Views: 1868

Answers (3)

mancini0
mancini0

Reputation: 4733

ctrl-shift-t to 'Open Type'.

Eclipse Version: 2019-03 (4.11.0)

Upvotes: 0

Kurt Du Bois
Kurt Du Bois

Reputation: 7665

Alternative is to try opening the file using ctrl (cmd on mac) + t. This way you can open a type and on the bottom of the popup it shows you in which jar-file the class is found.

Upvotes: 1

Andreas Dolk
Andreas Dolk

Reputation: 114817

Activate "Link with editor" in the Package Explorer (the double arrow) and press F3. Eclipse expands the class in a library. (Make sure, that the editor, that shows Persistence.class has the focus).

For the next step, assuming you use m2eclipse, open the pom editor and look at the Dependency Hierarchy Tab. That gives a first hint where the dependency comes from. It may be transitive.

Upvotes: 6

Related Questions