Given a class, org.eclipse.ui.views.navigator.ResourceNavigator for example, how do I find out which jar file to use? I know it\'s in org.eclipse.ui.ide, but how would I fin
You also have this eclipse plugin: jarclassfinder
The user enters the name of the class not found (or the name of the class that the Java project needs to access). The plug-in will search the selected directory (and subdirectories) for JAR files containing that class.
All results are displayed in a table in a custom view. The user can then browse this table and select the JAR file to add to his Java project's build path. The user then right-clicks on the entry in the table and, from the context menu, selects the build path to which to add it.
Update 2013, as I mention in "searching through .jar files eclipse", it is no longer maintained, and the alternatives are sparse.
As sunleo comments below:
with Eclipse, Ctfl+Shift+T remains the easiest alternative to look for a type
(with the jar name displayed in the status bar).
user862268 comments below:
For mac, it is cmd+shift+T in Eclipse to find the class and associated jar.
Use a class/JAR locator:
http://classlocator.sourceforge.net/
[EDIT] It isn't obvious, even from ClassLocator's docs (!) but it seems to be an Eclipse plugin.
In Intellij IDEA you just ctrl-click on class name and you are will be moved to pseudo source code of that class, and title of window will be like c:\path\to\lib.jar!\com\something\ClassName.class
If you have the jar in your class path / project path hit CTRL-SHIFT-T and type the name ... the jar will be displayed at the bottom.
If you haven't the class in your build path a) put together a dummy project containing all the jars b) I think there is a plugin to find jars from IBM Alphaworks (but that might be kind of outdated)
To answer the question, there is no real way to know which jar to use. Different versions will have potentially different behaviour.
When it comes to locating a jar which contains a given class, I use:
for f in `find . -name '*.jar'`; do echo $f && jar tvf $f | grep -i $1; done
This will highlight any jar containing the classname passed in as a parameter in any subfolder.
Another good way to find a class is to use the maven repos search.
Usually, I do jar -vtf foo.jar
to get a list of all the class files.
Not the most practical way, but handy. You can combine the result with grep, of course.