tags:

views:

143

answers:

4

Say you're working on a Java project in Eclipse and you're looking at a import statement like:

import com.somefirm.somepackage.AClass;

and the classpath for the project has a million and one .jars on it.

How do you determine where the import is coming from?

+3  A: 

I like to go to the Navigate menu, Open Type... (or Ctrl-Shift-T is quicker), then type in the class name and see the list of possible jars where it could be coming from. You can also use wildcards in the classname you type if you want to see some similarly-named and sometimes related classes.

Now if it lists more than one jar you'll have to try one the methods (F3 or F4) listed in the other answers here, but this is a quick way to see. Worst case scenario is that you'll have more than one version of the same jar.

dustmachine
+2  A: 

And if the class is not found into your IDE you can use this resource to find classes in jars. http://www.jarfinder.com/

Rodrigo Asensio
+5  A: 

Open declaration (F3) on the import line. This will open the Java or Class file that the import resolves to.

Once that files is open, you can right-click on the declared type and choose "Show In->Package Explorer" to see where it is declared.

Alternately, if "Link with Editor" is selected in Package Explorer, the related package/jar will already be open for your inspection.

David Citron
+1  A: 

if you select the name AClass and hit F4 which will bring up the class hierarchy, and the jar name will be on the status bar.

akf