How to get 2 different ClassLoader in one JVM?

C

chris_auw

I call ClassLoader.getClassLoader() and
Thread.currentThread.getContextClassLoader() but i always get the same
ClassLoader instance.
I want to load my interfaces and abstract classes by one ClassLoader
and load my concrete classes by another ClassLoader.How can i achieve
this?
 
P

pete kirkham

chris_auw said:
I call ClassLoader.getClassLoader() and
Thread.currentThread.getContextClassLoader() but i always get the same
ClassLoader instance.
I want to load my interfaces and abstract classes by one ClassLoader
and load my concrete classes by another ClassLoader.How can i achieve
this?

Create an instance of ClassLoader, probably URLClassloader for most
uses, and call it's loadClass methods.

But AFAIK you cannot have a class that implements an interface which is
loaded by a classloader with is not the same as or a child of the
interface's class loader, so you need to get th dependencies between
them right.


Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top