The Artima Developer Community
Sponsored Link

Legacy Design Forum
Designing with Dynamic Extension



This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


Solution for Reloading class files

Posted by Fasu on February 04, 2002 at 3:35 AM

Actually, there is a way...

First of all, you put your MainSomething class to some
directory. Under that directory you'll create a directory
called reloadables (which MUST NOT exist in CLASSPATH).

Then you compile your reloadable class files to reloadables/
directory. Then you just use the code below. ActionHandler
is just a simple interface, which implements handleAction-method.

Nothing too complex, I think you'll get hang of this :)

try {
URL[] serverURLs = new URL[]{new URL("file:reloadables/")};
cl=new URLClassLoader(serverURLs);
String className="SomeClass";
actionHandler=(ActionHandler) cl.loadClass(className).newInstance();
catch( Exception e )


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us