The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
Rich Internet applications (RIAs) are cached locally to improve startup time. 富互联网应用程序(RIA)在本地缓存,以缩短启动时间。However, before launching a RIA, the launch software checks to make sure that every JAR file referenced in the RIA's Java Network Launch Protocol (JNLP) file is up-to-date. 然而,在启动RIA之前,启动软件会检查以确保RIA的Java网络启动协议(JNLP)文件中引用的每个JAR文件都是最新的。In other words, the launch software makes sure that you are running the latest version of the RIA and not an older cached copy. 换句话说,启动软件确保您运行的是最新版本的RIA,而不是旧的缓存副本。These update checks can take up to a few hundred milliseconds depending on the number of JAR files and network speed. Use the techniques described in this topic to avoid unnecessary update checks and to enhance the start up time of your RIA.根据JAR文件的数量和网络速度,这些更新检查可能需要数百毫秒。使用本主题中描述的技术来避免不必要的更新检查,并提高RIA的启动时间。
The term "launch software" is used here to collectively refer to the Java Plug-in software and the Java Web Start software. 这里使用的术语“启动软件”是指Java插件软件和Java Web Start软件的统称。The Java Plug-in software launches applets while the Java Web Start software launches Java Web Start applications.Java插件软件启动小程序,而Java Web Start软件启动Java Web Start应用程序。
You can leverage the version download protocol to eliminate unnecessary version checks. 您可以利用版本下载协议来消除不必要的版本检查。See the following steps to enable this protocol.请参阅以下步骤以启用此协议。
<JAR file name>__V<version number>.jar
DynamicTreeDemo.jar
to DynamicTreeDemo__V1.0.jar
.DynamicTreeDemo.jar
重命名为DynamicTreeDemo__V1.0.jar
。jnlp.versionEnabled
property to true
. jnlp.versionEnabled
属性设置为true
。<resources> <!-- Application Resources --> <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se" max-heap-size="128m" /> <jar href="DynamicTreeDemo.jar" main="true" version="1.0"/> <jar href="SomeOther.jar" version="2.0"/> <property name="jnlp.versionEnabled" value="true"/> <!-- ... --> </resources>
When the 启用jnlp.versionEnabled
property is enabled, the launch software performs only one update check to make sure that the JNLP file is up-to-date. jnlp.versionEnabled
属性后,启动软件只执行一次更新检查,以确保JNLP文件是最新的。The software compares the version numbers that are specified in the JNLP file with the corresponding JAR file versions (according to the naming convention mentioned in step 1) and updates only the outdated JAR files. 软件将JNLP文件中指定的版本号与相应的JAR文件版本进行比较(根据步骤1中提到的命名约定),并仅更新过时的JAR文件。This approach is efficient because only the update check for the JNLP file occurs over the network. 这种方法非常有效,因为只有JNLP文件的更新检查通过网络进行。All other version checks occur locally.所有其他版本检查都在本地进行。
If a file with the correct version number is not found, the launch software attempts to load the default JAR file (for example, 如果找不到具有正确版本号的文件,则启动软件会尝试加载默认JAR文件(例如DynamicTreeDemo.jar
).DynamicTreeDemo.jar
)。
If it is not critical for the user to immediately run the latest version of your RIA, you can specify that all update checks should occur in the background. 如果用户不需要立即运行最新版本的RIA,则可以指定所有更新检查都应在后台进行。In this case, the launch software launches the locally cached copy for immediate usage and downloads a newer version of the RIA in the background. 在这种情况下,启动软件会启动本地缓存的副本以供立即使用,并在后台下载RIA的更新版本。The newer version of the RIA will be launched the next time the user attempts to use your RIA. 新版本的RIA将在用户下次尝试使用您的RIA时启动。To enable background update checks, add the following line to your JNLP file:要启用后台更新检查,请在JNLP文件中添加以下行:
<update check='background'/>
The following code snippet shows a sample JNLP file with the background update check enabled:下面的代码片段显示了启用后台更新检查的示例JNLP文件:
<?xml version="1.0" encoding="UTF-8"?> <jnlp spec="1.0+" codebase="" href=""> <information> <title>Applet Takes Params</title> <vendor>Dynamic Team</vendor> </information> <resources> <!-- Application Resources --> <j2se version="1.6+" href= "http://java.sun.com/products/autodl/j2se"/> <jar href="applet_AppletWithParameters.jar" main="true" /> </resources> <applet-desc name="Applet Takes Params" main-class="AppletTakesParams" width="800" height="50"> <param name="paramStr" value="someString"/> <param name="paramInt" value="22"/> </applet-desc> <update check="background"/> </jnlp>