wood burning stoves*
The moose likes Java in General and the fly likes interogating jars for specific classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "interogating jars for specific classes" Watch "interogating jars for specific classes" New topic
Author

interogating jars for specific classes

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

i am trying to write a method that goes around my classpath finding jars (that bit done and sorted using a url classloader).
then i want to interogate the jars hunting for any look and feels (so any class extending LookAndFeel)
here is my current attempt:






what am i supposed to do next?
i hope i have given enough information

edit:
Forgot to add this code has been copied from somewhere else in the application, but that insited the class name it was hunting for finished with CustomerAddOn, so i can't nick the rest of it. I considered reflection but that sounded far too heavyweight.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4167
    
  21

It appears that the class you are trying to load is not present in the ClassLoader represented by 'currentClassLoader'. If the currentClassLoader is an instance of URLClassLoader you should first add the URL to the JAR before trying to load the class. Alternatively, if you already added the JAR to a ClassLoader, user that one to load the class file.


Steve
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Also, don't forget that any libraries needed by those classes need to be loaded by that class loader as well. So make sure that either the URLClassLoader has loaded them, or they are loaded by a class loader which you then use to construct the URLClassLoader.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

well i have solved my own problem with:


but now i am 1 worried about rob's comment and 2 getting: java.lang.OutOfMemoryError: PermGen space.

I have decided to only load look and feels that end with LookAndFeel thus stopping me loading 12723 classes before running out of permgen memory


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interogating jars for specific classes
 
Similar Threads
extract .rar file with java
dynamically loading a class file from a jar file
How to get number of top-level files/directories ina Jar file?
Images and Text Files
java.util.zip.ZipException: The system cannot find the path specified