ClassLoader problem

Discussion in 'Java' started by Emmanuel PIC, Jul 30, 2003.

  1. Emmanuel PIC

    Emmanuel PIC Guest

    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?
    Emmanuel PIC, Jul 30, 2003
    #1
    1. Advertising

  2. 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)
    Lee Fesperman, Jul 31, 2003
    #2
    1. Advertising

  3. Emmanuel PIC

    Roedy Green Guest

    On Wed, 30 Jul 2003 11:26:06 +0200, Emmanuel PIC <> 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.
    Roedy Green, Aug 1, 2003
    #3
  4. Emmanuel PIC

    Emmanuel PIC Guest

    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 :/

    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.
    >
    Emmanuel PIC, Aug 4, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark F

    Tomcat classloader problem

    Mark F, Mar 5, 2004, in forum: Java
    Replies:
    0
    Views:
    478
    Mark F
    Mar 5, 2004
  2. Andrew Thompson

    Problem with methods & classloader

    Andrew Thompson, Oct 8, 2004, in forum: Java
    Replies:
    6
    Views:
    374
    Andreas Solsbach
    Oct 8, 2004
  3. Benji
    Replies:
    1
    Views:
    460
    Chris Uppal
    Oct 6, 2005
  4. Edward
    Replies:
    1
    Views:
    952
    Edward
    Feb 14, 2006
  5. sabine
    Replies:
    0
    Views:
    923
    sabine
    Oct 11, 2006
Loading...

Share This Page