File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes how to search a class in list of  jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "how to search a class in list of  jar files" Watch "how to search a class in list of  jar files" New topic
Author

how to search a class in list of jar files

Rr Kumaran
Ranch Hand

Joined: Sep 17, 2001
Posts: 548
Hi All,

I am using Windows XP. I have some 100's of jars and I want to find in which jar file a particular class exists. The search option in Windows XP (except Windows 2000) doesn't help. I tried the sourceforge.net jarbrowser tool but it's search functionality is not working.

Can anybody please suggest a nice tool or approach ...


Thanks & Regards,
Kr.


RR Kumaran
SCJP 1.4
Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 223

hi its sort of zip file format ...
U can use any un zip tolls like winzip or winace.. to unzip....


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
http://www.jarhoo.com/ has already searched many (many!) publicly available jars for you. If you're looking for something you downloaded from IBM or open source it might already be there.

A jar searcher might be fun to write. You can use the zip IO classes in Java.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 944
I don't know if this will work, but let run this past you.

Could you put all those jar file on your classpath, try to load that class, and if successful use findResource() from ClassLoader to see where that class came from? Would the URL returned from findResource() have the jar file name?

Ryan
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

here is a unix-solution:


drawbacks:
you need to specify the whole classname, including package.
"PdfPTable.class" will not work.

to convert it to windows, replace $XXX with %XXX%

And you need the unix-utils, to perform 'find, grep, head'.
And since windows has it's own 'find', you have to replace 'find' with the whole path where you installed the unix-utils.

Another solution:
Create an directory for index-files:


later you may do a simple grep:

Advantage: now you may look for classnames without package-name and class-extension.
If you (delete and) recreate the index by a script, it's easy to keep it up to date.

[ July 21, 2005: Message edited by: Stefan Wagner ]
[ July 21, 2005: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to search a class in list of jar files
 
Similar Threads
Windows XP shits, sorry cheats, with *.java files
Windows Native Jar Equivalent Tool
Main class not found
Windows XP shits, sorry cheats, with *.java files
commands for grep the class