Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ClassLoader problem

Reply
Thread Tools

ClassLoader problem

 
 
Emmanuel PIC
Guest
Posts: n/a
 
      07-30-2003
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?

 
Reply With Quote
 
 
 
 
Lee Fesperman
Guest
Posts: n/a
 
      07-31-2003
Emmanuel PIC wrote:
>
> 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.

--
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
================================================== ============
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-31-2003
On Wed, 30 Jul 2003 11:26:06 +0200, Emmanuel PIC <(E-Mail Removed)> wrote
or quoted :

>
>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?


see http://mindprod.com/jgloss/classloader.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Emmanuel PIC
Guest
Posts: n/a
 
      08-04-2003
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(class Loader);
</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 :/

Lee Fesperman wrote:

> Emmanuel PIC wrote:
>
>>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.
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ClassLoader problem in embedded tomcat sabine Java 0 10-11-2006 07:14 PM
classloader problem for data protocol URL using WSAD 5 Edward Java 1 02-14-2006 02:36 PM
Subclassed ClassLoader problem with array types Benji Java 1 10-06-2005 10:00 AM
Problem with methods & classloader Andrew Thompson Java 6 10-08-2004 02:09 PM
Tomcat classloader problem Mark F Java 0 03-05-2004 02:33 PM



Advertisments