squeezy
squeezy

Reputation: 627

What jar file an import uses?

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

Upvotes: 1

Views: 340

Answers (2)

Farvardin
Farvardin

Reputation: 5424

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.

Upvotes: 0

Dinal
Dinal

Reputation: 661

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

Upvotes: 3

Related Questions