ClassLoader problem

E

Emmanuel PIC

Hi,

I've written my own ClassLoader, and I'd like to use it to load my
application. Unfortunately, I don't know how to specify the ClassLoader
to be used by the JVM... Any idea?
 
L

Lee Fesperman

Emmanuel said:
Hi,

I've written my own ClassLoader, and I'd like to use it to load my
application. Unfortunately, I don't know how to specify the ClassLoader
to be used by the JVM... Any idea?

You don't actually replace the standard ClassLoader; you load your class(es) with the
ClassLoader, and it becomes the default ClassLoader for those classes.

Use the loadClass() method in your ClassLoader or use the form of Class.forName() which
takes a ClassLoader as a parameter to load your classes.
 
E

Emmanuel PIC

Actually, I've found out how to specify the classloader used. The
following isntruction allows to specify the classloader used in the
current thread :

<code>
Thread.currentThread().setContextClassLoader(classLoader);
</code>

Thus when called from the main, it will specify the classloader used in
the main thread, which answers my problem :)

PS : sorry for my pathetic english :/
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top