Re: Dynamic Class loading

Christian Rick <[email protected]> Mon, 3 Jun 2002 10:49:58 +0200
Newsgroups gmane.comp.windows.devel.java.general
Message-ID <[email protected]>
I once did something similar only that i loaded a class from a =
directory not
specified in the classpath. What i did was to write my own subclass of
ClassLoader and then use the following statements to load the class:

        Class ClassDesc =3D Class.forName("MyTestSubClass", false, new
MyClassLoader());
        MyTestClass MySubClass =3D (MyTestClass) ClassDesc.newInstance();
        MySubClass.doSomething();

I do not blelive that loading a class from a jar file should be any =
more
difficult. If I remember right there are classes for handling jar =
files. If
you want to look at my ClassLoader sublass please tell me and I'll =
email it
to you.


Best regards
/Christian Rick



-----Ursprungligt meddelande-----
Fr=E5n: Suresh Babu Koya [mailto:[email protected]]
Skickat: den 31 maj 2002 19:22
Till: [email protected]
=C4mne: [JAVA] Dynamic Class loading


Hi all,

  Has anyone tried loading a class from a jar file not specified in the
class path. I have tried to do that
  by modifying "java.class.path" after application startup and loading =
the
class with Class.forName("com.xyz.test").

  While running I get a class not foung exception. How can I acheive my
objective. Any help is appreciated.

Regards,
Suresh

You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at =
http://discuss.develop.com.

You can read messages from the JAVA archive, unsubscribe from JAVA,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.