File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

interogating jars for specific classes

Wendy Gibbons

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

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

Joined: Jan 28, 2003
Posts: 4181

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.

Rob Spoor

Joined: Oct 27, 2005
Posts: 20269

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.

How To Ask Questions How To Answer Questions
Wendy Gibbons

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:
subject: interogating jars for specific classes
It's not a secret anymore!