1

I've downloaded an example code that has some imports, e.g:

import com.sun.net.httpserver.HttpExchange;

I have the relevant jars in my build-path, and no warning appears. But how do I know from which jars exactly I import the above? (I want to know this so I can add javadocs to those jars).

I use Eclipse IDE

6

2 Answers 2

3

If you are using Eclipse IDE or IBM RAD, WSAD etc, Press Ctrl+Shift+T in eclipse window. Now type the name of the class file. It will show the contained jar.

For eg: HttpExchange is present in rt.jar

enter image description here

3
  • 1
    I don't see the jar, just the packages, e.g: com.sun.net.httpserver - [jdk1.7.0_60]
    – squeezy
    Jun 9, 2014 at 7:58
  • 1
    @fatsokol That "jdk" line means it's part of the standard JVM libraries (as does the com.sun namespace, whose classes you should almost never use explicitly, since they're not an official part of the platform). Jun 9, 2014 at 8:04
  • @fatsokol Have added a screenshot. Open the class file in eclipse. Enable "Link with editor" button. So here you can see AWTUtilities is present in rt.jar. Similarly you can find others as well.
    – Dinal
    Jun 9, 2014 at 8:14
0

in linux you can use shell-script to view inside all jar files. something like this may help you:

for i in $(ls *.jar)
do
  unzip -l $i | sed -r "s/^[ 0-9:\-]+/$i /" | grep ".class" | tr '/' '.'
done

the output is a pair of (jar-name, class-fullname) for example:

Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.NewsCollection.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.NoColumnCollection.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.NoHeaderCollection.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.PanelInterface.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.ParentFinder.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.SelectionHelper.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.TabsInterface.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.TabsUtil.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.TagUtils.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.TreeviewInterface.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.util.WidgetUtils.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.workflow.LayoutPlugin.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.workflow.LayoutRequestProcessor.class
Struts-Layout-1.2.jar fr.improve.struts.taglib.layout.WriteTag.class

you can search your class in this output to find jar-file name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.