Java Reference
In-Depth Information
java.lang.NoClassDefFoundError s when programs are trying to invoke still unloaded classes
on an online connection). Java Web Start supports lazy download, and this example will run
correctly.
N OTE
With IDE JAR packagers (those development tools that analyze dependencies and
include mechanically all the needed items in a JAR file), this little experiment may not
work because the tool automatically puts the lazy resources into the main JAR file,
eliminating all our testing efforts. A way to work around this, if it happens to be a
problem, is to invoke classes by means of Class.forName() ; that is, the dynamic load-
ing of Java classes to fool dependency compilers. Anyway, it should be avoided if not
really needed because it could produce more troubles than those it solves. This trou-
ble could appear both at compile time, when the benefits of static type-checking are
reduced, and during execution, when extensive (and unnecessary) dynamic class load-
ing degrades performances.
Finally, what happens when the application is run offline? The even more powerful JNLP
Client will throw a java.lang.NoClassDefFoundError . Every technology has its own limits.
Specifying Packages
When we declare the download type of a given resource as lazy , we don't tell the JNLP Client
in which JAR file to look for given classes when they are needed. This could be very handy
and can be obtained using the package element, which instructs the JNLP Client which classes
are in which JAR files.
The package element has three attributes:
name . The Java fully qualified name of a single class or a package. It specifies what is
inside the JAR files that makes up that given part. For example, the following line tells
the JNLP Client that the package “com.myCompany.jnlp.*” is in one of the JAR files of
the “part1” part:
<package name=”com.myCompany.jnlp.*” part=”part1”>
Whenever the JNLP Client needs a class from that package, it knows which JAR files to
download.
part .The part that contains the given class or packages specified in the name attribute.
recursive . It can have only Boolean values. When set to true, this value tells the JNLP
Client that subpackages also have to be considered.
10
Search WWH ::




Custom Search