Java Reference
In-Depth Information
L ISTING 11.6 Continued
} catch (Exception e) {
System.out.println(“creating & writing “+jarName+”: “+e);
public static void main(String[] args) {
InstallerExample installer = new InstallerExample();
There are some interesting things to notice in this listing:
•First, notice the sequence of actions that an installer usually follows. First, it obtains the
ExtensionInstallerService (line 17-18); then, it prepares the GUI, both creating it by
itself or adapting the JNLP Client's one, using methods of the previously obtained
ExtensionInstallerService (method setupDownloadWindow at lines 27-30). Then, it
performs its operations in the method doResourcesDownload (lines 31-33), eventually
calling setJREInfo or setNativeLibraryInfo for notifying changes to the JRE, and
finally concludes the installation procedure, as in method installationCompleted at
lines 34-44.
•Also, notice how to locate the directory where a JRE is currently installed, by using the
following, as shown in Line 55:
Note that the JRE URL is the vendor's URL, and it can be determined together with the
exact version string directly from the Preferences control panel of Java Web Start or in an
analogous way for other JNLP Clients.
• The method installOptionalPackage beginning at line 45 first tries to determine where
the JRE Java executable is located. Then, it creates the proper path where the resources
are intended to be downloaded.
• Lastly, just a note on threads. Despite the fact that they are not needed in this simple
example, they are commonly used by installers that want to reduce the total installation
The JNLP main file (namely installer-main.jnlp ) shown in Listing 11.7 declares its own
application JAR files and the installer extension, as reported in Listing 11.8.
Search WWH ::

Custom Search