loading classes into a running JVM
Tim Panton - Westhawk Ltd
tpanton at ibm.net
Sat Nov 12 19:29:10 PST 2005
Yes just add it to the classpath.
- with limitations- your class-b
would have to implement an already
defined Interface- say Loadable
in your class-a you have code
which says
String classb =getNewClassName();
Loadable b = (Loadable) Class.classForName(classb).newInstance();
b.whatever();
Or you need to use reflection.
"Hanes, Jeff x66258" <JHanes at bis.adp.com> wrote:
__________
>the recent flap about JVMs and classloaders leads me to the following
>question:
>
>is it possible to add a class to a running JVM from *outside* the JVM?
>
>for example,
>suppose i have two terminal windows open on the same machine (could be
>either WinNT or UNIX)
>
>in window 1, i type:
>
> java class_a
>
>so i have a JVM process running and doing whatever class_a does.
>
>leaving this running, i then go to window 2 ... is there anything i can type
>to add class_b to
>the *same* instance of the JVM process i started in window 1? if i
>understand things correctly,
>then class_b could invoke methods in class_a and vice versa.
>
>if i could get this work, it would save me a lot of headaches with file i/o.
>
>thanks in advance,
>Jeff Hanes
>
>
>---
>To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
>To get help, mail advanced-java-help at xcf.berkeley.edu
>
URL http://www.westhawk.co.uk/
---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu
More information about the Advanced-java
mailing list