Re: Applet class loading enquiry
On Jan 25, 12:47 pm, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
If anappletcomprises say 40 classes in 4 separate JARs, is Java "smart"
enough to only download the individual class files from within each JAR as
they are first accessed or will accessing one class in a JAR cause a
download of the entire JAR before methods in that class can be invoked?
That depends. If the Jar's are listed in the
archives attribute of the applet element, no.
<http://java.sun.com/j2se/1.4.2/docs/guide/misc/applet.html>
"ARCHIVE = archiveList
This OPTIONAL attribute describes one or more
archives containing classes and other resources
that will be "preloaded". .."
OTOH, it is not necessary to list archives in the
archive attribute. An applet can get classes from
oher Jar's as well, using (for e.g.) an URLClassLoader.
Java webstart has more options for supplying Jar's
lazily, but this use case would require some extra
programming. Calls to instantiate a class (or use
a static method etc.) from a 'lazy' jar will generally
invoke the download and caching of the archive, but
that does not work for reflection and Class.forName(),
which will fail unless the class has already been
cached locally.
--
Andrew T.
PhySci.org