How to find which classes implement a particular interface in Eclipse?

JavaEclipseInterface

Java Problem Overview


I have an application as JAR file with many dependencies. For some reason I need to decompile one of the libraries and open it up with Eclipse. For a given interface in the project, is there a way to find the class(s) that implements it? It may be the case that the interface was implemented in other library that I didn't decompile yet. Is it possible to do this for this kind of classes?

Java Solutions


Solution 1 - Java

Right-click on the interface, and choose "Open type hierarchy". Then click on "Show the subtype hierarchy".

Solution 2 - Java

Try Ctrl+T after selecting the classname; should work in Java Perspective.

Solution 3 - Java

You can "Show Type Hierarchy" on the item (Right Click to choose this option or press F4 when the item is highlighted)*.

However, this will list only items in those projects that are referred ("dependent"). Not in others.

So if you have decompiled a jar, and there is another jar that you have not decompiled, then the implementations (of the interface) in that jar will not be listed.

Also, say you have decompiled a jar as a project and there is another project that is referring to the jar, and not the decompiled project, implementations in that will also not be listed.

So you will have to decompile all jars and add them as projects (and add references via "Java Build Path") to make sure all the implementations in the jars of your choice are listed.

* Quick type Hierarchy, ctrl + T will show a similar structure in a tooltip/autocomplete kind of panel. But the complete type hierarchy is more useful for the type of analysis you are intending to do.

Solution 4 - Java

There is radio-button "Implementors" in Java Search.

Solution 5 - Java

Or right-click and select Quick Type Hierarchy for a pulldown menu of extending interfaces and implementing classes.

Solution 6 - Java

Ctrl + H (Search Option) Open Java Search perspective and, enter the interface name, click Implementors radio button and you will find which classes implement a particular interface. Same as answer from stackexchanger above

Solution 7 - Java

Select the class name, then 'F4' in Eclipse (Windows environment)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAm1rr3zAView Question on Stackoverflow
Solution 1 - JavaJB NizetView Answer on Stackoverflow
Solution 2 - JavaScorpionView Answer on Stackoverflow
Solution 3 - JavaNivasView Answer on Stackoverflow
Solution 4 - JavaVladView Answer on Stackoverflow
Solution 5 - JavaSean Patrick FloydView Answer on Stackoverflow
Solution 6 - JavaRohit MathurView Answer on Stackoverflow
Solution 7 - JavaFullStackDeveloperView Answer on Stackoverflow