Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

how to know what jar file contain my needed class

Thread view: 
david wolf - 28 Mar 2006 16:35 GMT
When I am using other people's code(say jwsdp tutorial examples) and
try to compile it. sometimes I got compile error. For example, it says
it needs the following package /class:

com.sun.tools.xjc.api

Which jar file contain this package.

Or more generally, when you guys have this kind of problem, how to know
which jar file contain the class I want?

David
Dave Mandelin - 28 Mar 2006 20:02 GMT
I wrote a program to do this for myself using the JarFile class, but I
doubt it is general or robust enough to be useful to anyone else.
JarBrowser on SourceForge looks like it will do the trick:

http://jarbrowser.sourceforge.net/

There's also a commercial utility (trial version available) that looks
like it will search most kinds of archive files, including jars. (I am
not associated with ZipScan in any way and know nothing about their
product, just found it by googling.)

http://www.zipscan.co.uk/

--
Need to get from a Foo object to a Bar object in Java?
   Ask Prospector:                http://snobol.cs.berkeley.edu
Want to play tabletop RPGs over the internet?
   Check out Koboldsoft RPZen:    http://www.koboldsoft.com
Roedy Green - 28 Mar 2006 20:38 GMT
>Or more generally, when you guys have this kind of problem, how to know
>which jar file contain the class I want?

I have a student project writeup at
http://mindprod.com/projects/which.html

If you have any budget, I would be happy to write such a tool for you.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Martin Gregorie - 28 Mar 2006 21:51 GMT
> Or more generally, when you guys have this kind of problem, how to know
> which jar file contain the class I want?

You didn't say what OS you're using, but I'd use a shell script.
Something like:

for f in *.jar
do
    echo "Jar file is $f"
    jar t $f | grep classname
done

where 'classname' is the name of the class you're looking for. As a
bonus you'll also be told the package name as well. That works for any
*nix system.

You could do essentially the same in Java by using the JarFile, Manifest
and Pattern classes. Use JarFile to pull the Manifest out of each jar
file and Pattern to search the output stream you can get from the Manifest.

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |

Lee Peedin - 28 Mar 2006 23:31 GMT
>When I am using other people's code(say jwsdp tutorial examples) and
>try to compile it. sometimes I got compile error. For example, it says
[quoted text clipped - 8 lines]
>
>David

Dang,
I've only been toying with Java for a couple of months and that's one
of the first things I did.  And you guys are trying to get him to buy
something. :-(

The "entries" method of "java.util.zip.ZipFile" works on jar files as
well as zip files it will return an enumeration - "size" will tell you
how many files are in the jar.

Lee


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.