Java:我如何知道使用哪个jar文件给定一个类名? [英] Java: How do I know which jar file to use given a class name?
问题描述
给定一个类, org.eclipse.ui.views.navigator.ResourceNavigator ,例如,如何找出要使用的jar文件?我知道这是在org.eclipse.ui.ide中,但是如何才能找到?
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 find that out?
修改:谢谢你们谁回答像许多事情一样,似乎有几种方式来皮肤这只猫。我希望javadoc包含这个信息。到目前为止,这里有不同的方法:
Edit: Thank you to all of you who answered. Like many things, there seems to be several ways to skin this cat. I wish javadoc contained this info. So far here are the different methods:
-
没有Internet,Eclipse或NetBeans:
Without Internet, Eclipse or NetBeans:
for f in `find . -name '*.jar'`; do echo $f && jar tvf $f | grep -i $1; done
如果你想在本地找到使用Eclipse:
If you want to find out locally using Eclipse:
- JAR Class Finder Plug-in
- Class Locator Plug-in
如果你想从互联网上找到,或者你还没有罐子:
If you want to find out from Internet or you do not have the jar yet:
- jarFinder
推荐答案
你还有这个eclipse插件: jarclassfinder
You also have this eclipse plugin: jarclassfinder
用户输入未找到类的名称(或名称Java项目需要访问的类)。该插件将搜索包含该类的JAR文件的所选目录(和子目录)。
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.
所有结果都显示在自定义视图中的表中。然后,用户可以浏览此表并选择要添加到其Java项目的构建路径的JAR文件。然后用户右键单击表中的条目,并从上下文菜单中选择要添加到其中的构建路径。
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.
更新2013,正如我在搜索.jar文件eclipse ,它不再维护,替代品是稀疏的。
Update 2013, as I mention in "searching through .jar files eclipse", it is no longer maintained, and the alternatives are sparse.
使用Eclipse, Ctfl + Shift + T 仍然是最简单的选择寻找一个类型
(名称显示在状态栏中)。
with Eclipse, Ctfl+Shift+T remains the easiest alternative to look for a type
(with the jar name displayed in the status bar).
user862268 评论以下:
对于mac,它是Eclipse中的 cmd + shift + T ,以查找类和关联的jar。 p>
For mac, it is cmd+shift+T in Eclipse to find the class and associated jar.
这篇关于Java:我如何知道使用哪个jar文件给定一个类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!