Java: How do I know which jar file to use given a class name?

前端 未结 17 1279
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 09:47

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

相关标签:
17条回答
  • 2020-12-02 10:02

    Also check http://javacio.us/.

    0 讨论(0)
  • 2020-12-02 10:09
    **shell> find . -name "*.jar" | xargs -i -t \jar tvf {} | grep [TheClassNameYouAreLookingFor]**
    

    For example, if you are looking for a class LogFactory.class on list of apache commons jars, below command would work

    shell> find apache-commons/ -name "*.jar" | xargs -i -t \jar tvf {} | grep LogFactory.class
    
    jar tvf apache-commons/commons-beanutils-1.7.0.jar
    
    jar tvf apache-commons/commons-fileupload-1.2.1.jar
    
    jar tvf apache-commons/commons-lang-2.3.jar
    
    **jar tvf apache-commons/commons-logging-1.1.jar**
    
    **21140 Tue May 09 23:08:12 EDT 2006 org/apache/commons/logging/LogFactory.class**
    
    jar tvf apache-commons/commons-net-1.3.0.jar
    

    The above result indicates that the match is commons-logging-1.1.jar

    0 讨论(0)
  • 2020-12-02 10:10

    IntelliJ IDEA plugin (Class Hunter)

    0 讨论(0)
  • 2020-12-02 10:11

    if you tell eclipse to open a declaration (F3) or implementation (Navigate->Open Implementation) and you get popped into an un-editable edit window, you can see the path to the jar file by right-clicking the editor window and choosing 'show in breadcrumbs'

    my find unix based:

    find . -name "*.jar" -print -exec jar -tf {} \; >outputfile
    

    edit output file to find what you want (instead of grep)

    0 讨论(0)
  • 2020-12-02 10:16

    I'm not sure I really understand the question, but if you're looking to verify that your class is really in the jar, you can always look through the jar itself, and for that you don't need any Eclipse plugins or specialized external application.

    JAR (Java ARchive) files are nothing more than ZIP files. All you have to do is unzip the jar, or even view it using a zip-reading application. Under Windows XP, for example, this comes built into the operating system. How convenient.

    Hope this helped...

    Yuval =8-)

    0 讨论(0)
  • 2020-12-02 10:17

    I use FindJar.com. It lists all known packages that contain any given class! It's incredibly helpful.

    0 讨论(0)
提交回复
热议问题