Java:我如何知道给定类名要使用哪个 jar 文件? [英] Java: How do I know which jar file to use given a class name?

查看:32
本文介绍了Java:我如何知道给定类名要使用哪个 jar 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个类,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:

  1. 没有 Internet、Eclipse 或 NetBeans:

  1. 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:

    If you want to find out from Internet or you do not have the jar yet:

    推荐答案

    您还有这个 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.

    所有结果都显示在自定义视图的表格中.然后,用户可以浏览此表并选择 JAR 文件以添加到他的 Java 项目的构建路径中.然后,用户右键单击表中的条目,并从上下文菜单中选择要将其添加到的构建路径.

    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.

    作为 sunleo 评论 下面:

    对于 Eclipse,Ctfl+Shift+T 仍然是寻找类型的最简单替代
    (在状态栏中显示 jar 名称).

    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.

    For mac, it is cmd+shift+T in Eclipse to find the class and associated jar.

    这篇关于Java:我如何知道给定类名要使用哪个 jar 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆