How to find the ClassLoader with a static method ?

Discussion in 'Java' started by Philippe Poulard, Jul 22, 2003.

  1. Hi,

    I got a static method of a class that needs to retrieve the class loader
    used for this class, but I don't have any instance of it.

    I must -actually- have an instance of this class before to retrieve the
    appropriate class loader.

    Is it possible to retreive the class loader of a class that has no
    instance yet ?
    How should I do ?

    Thanks.
    Philippe Poulard
     
    Philippe Poulard, Jul 22, 2003
    #1
    1. Advertising

  2. Thomas Kellerer wrote:
    > Philippe Poulard schrieb:
    >
    >> Hi,
    >>
    >> I got a static method of a class that needs to retrieve the class
    >> loader used for this class, but I don't have any instance of it.
    >>
    >> I must -actually- have an instance of this class before to retrieve
    >> the appropriate class loader.
    >>
    >> Is it possible to retreive the class loader of a class that has no
    >> instance yet ?
    >> How should I do ?
    >>
    >> Thanks.
    >> Philippe Poulard
    >>

    > Assuming your class is called MyClass, then you can retrieve the
    > classloader using
    >
    > MyClass.class.getClassLoader()
    >
    > Thomas
    >


    Thanks, that's exactly what I need.
     
    Philippe Poulard, Jul 22, 2003
    #2
    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. =?ISO-8859-1?Q?Thomas_Gagn=E9?=

    Why do static and non-static method names collide?

    =?ISO-8859-1?Q?Thomas_Gagn=E9?=, Jul 2, 2003, in forum: Java
    Replies:
    12
    Views:
    5,768
    cgbusch
    Jul 5, 2003
  2. Gary
    Replies:
    1
    Views:
    4,066
    Ryan Stewart
    Jan 16, 2004
  3. Michael
    Replies:
    3
    Views:
    4,973
    Adam Jenkins
    Jan 27, 2004
  4. G. Burton
    Replies:
    2
    Views:
    59,947
    Sudsy
    Feb 21, 2004
  5. Kenny
    Replies:
    22
    Views:
    983
    Adam Maass
    Feb 20, 2006
Loading...

Share This Page