Developers guide
52
6.3.3 Resource loading
Resources such as images, sounds, and any other additional application files cannot simply be
referenced in the same way a normal application would. There are two major restrictions:
• All resources must be packaged in jar files. Primarily to support versioning and
download management for JNLP clients.
• File paths cannot be used to reference the contents of these jar files. The JNLP
specification does not stipulate where or in what form the applications are handled on
the client side. Java Web Start, for example, renames downloaded jar files for caching
purposes.
Consequently, the Web Start Developers Guide [ 45 ], provides the following construct to load
resources. Note that the getResource() method returns a Java URL Object.
// Get current classloader
ClassLoader cl = this.getClass().getClassLoader();
// Create icons
Icon saveIcon = new ImageIcon(cl.getResource("images/save.gif"));
Icon cutIcon = new ImageIcon(cl.getResource("images/cut.gif"));
...
Figure 6-3 Suggested resource loading
Although this may seem a trivial modification to existing applications, complications can arise.
For example, the SkinnedTextField, discussed in Chapter 8, requires a ZipFile object in the
constructor of a TextSkin. The creation of a ZipFile from a URL is not a trivial operation. For this
reason TextSkin packages must be downloaded and installed manually.
The free package Rachel
i
, designed to simplify resource loading, is used in the APT Client
application to load Skin Packages for the Skinned Look and Feel, discussed in 5.6.1.
6.4 Compilation
The Java based build tool ant is used to control compilation and deployment. Each CVS module
is accompanied by a build.xml configuration file. This file specifies various targets, tasks, and
dependency information required to compile and deploy the application.
The software deployment system can be seen in Figure 6-4. This diagram shows the usages of the
different ant targets. Similar information is obtained using the “ant usage” target.
i
http://rachel.sourceforge.net










