Documentation

The Java™ Tutorials
Hide TOC
Reducing the Download Time减少下载时间
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Best Practices

Reducing the Download Time缩短下载时间

Rich Internet applications (RIAs) are downloaded from a web site when the user tries to access them. 当用户尝试访问富Internet应用程序(RIA)时,会从网站下载这些应用程序。(RIAs can be cached after the initial download to improve performance). (初始下载后可以缓存RIA以提高性能)。The time taken to download a RIA depends on the size of the RIA's JAR file. 下载RIA所需的时间取决于RIA JAR文件的大小。Larger JAR files take longer to download.较大的JAR文件下载时间较长。

You can reduce the download time of your RIA by applying the following techniques:通过应用以下技术,您可以减少RIA的下载时间:

The following steps describe how to create and deploy a compressed JAR file for a signed RIA.以下步骤描述了如何为签名RIA创建和部署压缩JAR文件。

  1. Normalize the JAR file using the --repack option. 使用--repack选项规范化JAR文件。

    This step ensures that the security certificate and JAR file will pass verification checks when the RIA is launched.此步骤确保安全证书和JAR文件在RIA启动时通过验证检查。

    pack200 --repack DynamicTreeDemo.jar
  2. Sign the normalized JAR file. 对规范化JAR文件进行签名。
    jarsigner -keystore myKeyStore DynamicTreeDemo.jar me
    where myKeyStore is the name of the keystore and me is the alias for the keystore.其中,myKeyStore是密钥库的名称,me是密钥库的别名。
  3. Pack the signed JAR file 打包已签名的JAR文件
    pack200 DynamicTreeDemo.jar.pack.gz DynamicTreeDemo.jar
  4. Set the jnlp.packEnabled property to true in the RIA's JNLP file. 在RIA的JNLP文件中,将jnlp.packEnabled属性设置为true
    <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.packEnabled property is set in the JNLP file, the Java Plug-in software looks for the compressed JAR file with the .pack.gz extension (for example, DynamicTreeDemo.jar.pack.gz). 当在JNLP文件中设置了jnlp.packEnabled属性时,Java插件软件将查找具有.pack.gz扩展名的压缩JAR文件(例如,DynamicTreeDemo.jar.pack.gz)。If found, the Java Plug-in software automatically unpacks and loads the JAR file. 如果找到,Java插件软件会自动解压缩并加载JAR文件。If a file with the .pack.gz extension is not found, then the Java Plug-in software attempts to load the regular JAR file (for example, DynamicTreeDemo.jar).如果找不到具有.pack.gz扩展名的文件,那么Java插件软件将尝试加载常规JAR文件(例如,DynamicTreeDemo.jar)。


Note: You need to deploy your RIA on a web server to test the jnlp.packEnabled property. 您需要在web服务器上部署RIA来测试jnlp.packEnabled属性。

Previous page: Deployment Best Practices
Next page: Avoiding Unnecessary Update Checks