The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Dynamic Extension



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


getting custom class loader to be used throughout application/applet

Posted by T.R. Missner on May 02, 2000 at 4:24 PM


I have written a custom class loader in using java 2.
In my custom class loader I override the findClass() method
in order to load classes from a jarConnection. All this is
working fine. My question is how can I get my custom class
loader to be used whenever another class is to be loaded. I
have used a small bootstrap class that creates my custom loader
and loads/invokes a main class. From there the main class creates other objects but it seems to use the primoridial class loader.

I have also had my main class create an instance of my custom class and load/instantiate a new class. Then the new class
creates another class using the new operator. I would expect
my custom class loader to be invoked but alas it seems that the
primordial class loader is used yet again.

I have read your column and book excerpt and can't figure out
why my custom class loader isn't be used 'automatically' after
I have used it to create parent classes. Could there be a scope
problem ( could the instance of my classloader be going out of scope ) I can't see how but have no other ideas.

The way I see it I should never get a ClassNotFoundException
without the findClass code I wrote being executed first ( assuming I loaded the application/class with my loader )

any ideas?


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us