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

前端 未结 17 1295
爱一瞬间的悲伤
爱一瞬间的悲伤 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 09:59

    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.

提交回复
热议问题