Rich Internet applications (RIAs) are downloaded from a web site when the user tries to access them. (RIAs can be cached after the initial download to improve performance). The time taken to download a RIA depends on the size of the RIA's JAR file. Larger JAR files take longer to download.
You can reduce the download time of your RIA by applying the following techniques:
- Compress your RIA's JAR file by using the
pack200tool.- Remove unnecessary white space from the Java Network Launch Protocol (JNLP) file and the JavaScript files.
- Optimize images and animation.
pack200compression for signed and unsigned RIAs is discussed in greater detail in this topic.Compressing the JAR File for an Unsigned RIA
The following steps describe how to create and deploy a compressed JAR file for an unsigned RIA.
- Compress the JAR file of your RIA.
// compresses DynamicTreeDemo.jar to produce DynamicTreeDemo.jar.pack.gz pack200 DynamicTreeDemo.jar.pack.gz DynamicTreeDemo.jar- Set the
jnlp.packEnabledproperty totruein the RIA's JNLP file.<resources> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="128m" /> <jar href="DynamicTreeDemo.jar" main="true"/> <property name="jnlp.packEnabled" value="true"/> ... ... </resources>Compressing and Signing RIA JAR File
The following steps describe how to create and deploy a compressed JAR file for a signed RIA. See the topic, Signing JAR Files Only When Necessary, to understand the impact of signing JAR files.
- Normalize the JAR file using the
--repackoption.This step ensures that the security certificate and JAR file will pass verification checks when the RIA is launched.
pack200 --repack DynamicTreeDemo.jar- Sign the normalized JAR file.
wherejarsigner -keystore myKeyStore DynamicTreeDemo.jar memyKeyStoreis the name of the keystore andmeis the alias for the keystore.- Pack the signed the JAR file
pack200 DynamicTreeDemo.jar.pack.gz DynamicTreeDemo.jar- Set the
jnlp.packEnabledproperty totruein the RIA's JNLP file.<resources> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="128m" /> <jar href="DynamicTreeDemo.jar" main="true"/> <property name="jnlp.packEnabled" value="true"/> ... ... </resources>When the
jnlp.packEnabledproperty is set in the JNLP file, the Java Plug-in software looks for the compressed JAR file with the.pack.gzextension (for example,DynamicTreeDemo.jar.pack.gz). If found, the Java Plug-in software automatically unpacks and loads the JAR file. If a file with the.pack.gzextension is not found, then the Java Plug-in software attempts to load the regular JAR file (for example,DynamicTreeDemo.jar).
Note: You need to deploy your RIA on a web server to test thejnlp.packEnabledproperty.