Set classloader (classpath?) at runtime

C

cyberco

I"m not sure if my understanding of classloading is correct, but I get
the feeling that it is where my problems lie.

I have a class that receives an object that uses a different
classloader/classpath. The incoming object knows nothing about classes
in the classpath of the receiving class. It should though. How can I
set the classloader of the incoming object so that it can find classes
(in the classpath) of the receiving class?

I hope I'm making sense :)
 
D

Daniel Pitts

cyberco said:
I"m not sure if my understanding of classloading is correct, but I get
the feeling that it is where my problems lie.

I have a class that receives an object that uses a different
classloader/classpath. The incoming object knows nothing about classes
in the classpath of the receiving class. It should though. How can I
set the classloader of the incoming object so that it can find classes
(in the classpath) of the receiving class?

I hope I'm making sense :)
If the class loader of one class is the parent of the class loader of
the other path, I think you should be okay. If not, you'll need to have
at least one interface that is loaded by a mutual parent in order for
the two classes to communicate without using reflection.

So, why exactly are you having this problem? Its not a common problem,
so I take it you have an unusual set up. It might help us to help you if
you tell us what your set up is and why. We might be able to tell you
how to "fix" you setup or tell you a different approach to what you're
trying to do.

HTH,
Daniel.
 

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
474,260
Messages
2,571,038
Members
48,768
Latest member
first4landlord

Latest Threads

Top