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.


Similar Problem - Please Help!!

Posted by Ankur Lahoti on September 03, 2000 at 8:02 AM

Dear Sir,
I am also trying to do a similar thing, that is trying to load class
files from jar files dynamically. Could you please elaborate a little on how are
are you getting to load a class from URLClassLoader. I am not clear how do you get
a newInstance of a URLClassLoader and then call findClass.
Thanking you in advance.
> I am trying to dynamically load classes from JAR files using
> the JDK 1.2 class URLClassLoader in an Applet without adding
> the policy to create class loaders. This doesn't quite seem
> like it should be possible, but I am able to do so by "getting"
> a URLClassLoader by calling the static method:
> URLClassLoader.newInstance(URL[] urls, ClassLoader parent). My
> first question is, how is this working without setting a policy?

> Next, I am having a slight performance problem with this
> technique. I was hoping that by specifying a URL for a JAR file,
> that loading my first class from the JAR file would also load
> the other classes from the JAR file. I think I see why that was
> not done, but the resulting problem is that when my class is
> getting resolved, the other dependent classes in the JAR file
> must be loaded. This is resulting in hits back to the web server
> for each class to see if each can be found in the CLASSPATH.
> This seems to be eating up much of the efficiency I was hoping
> to obtain by putting the classes in a JAR file to begin with. Do
> you see a way around this?

> Thanks in advance for any help.

> -- Kevin Welker


Sponsored Links

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