aspose file tools*
The moose likes Java in General and the fly likes Reflecting classes not in classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reflecting classes not in classpath" Watch "Reflecting classes not in classpath" New topic
Author

Reflecting classes not in classpath

Nickolay Kolev
Greenhorn

Joined: Oct 17, 2002
Posts: 16
Hi all,
Is there a way to load a class fo reflection wich is not in the classpath, but rather in the same directory as the reflecting class?
I am trying to load a class and examine its swing components...
Any tips on how this could be achieved?
Many thanks,
Nickolay Kolev
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I think you will need to use a custom ClassLoader for this. Don't know much more about it, though...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
You can use something like this:

And load classes like this:

Enjoy!
[ October 30, 2002: Message edited by: Dave Landers ]
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
Instead of writing your own Classloader, I guess you could use the built-in URLClassLoader for the same purpose:
 
Consider Paul's rocket mass heater.
 
subject: Reflecting classes not in classpath