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) usually need a minimum version of the Java Runtime Environment (JRE) software to be present on the client machine. 富互联网应用程序(RIA)通常需要在客户机上提供Java运行时环境(JRE)软件的最低版本。When deploying a RIA, you need to ensure that client machines have the required version of the JRE software so that your RIA can function well. 在部署RIA时,您需要确保客户端机器具有所需版本的JRE软件,以便RIA能够正常运行。With the Deployment Toolkit script, you have at least two ways to handle this requirement.使用部署工具包脚本,您至少有两种方法来处理此需求。
The following example checks if a user has at least version 1.6.0_13 of the JRE software installed. 以下示例检查用户是否安装了至少1.6.0_13版的JRE软件。If not, the code installs the latest JRE software. 如果没有,代码将安装最新的JRE软件。See inline comments in the code.请参阅代码中的内联注释。
<script src="https://www.java.com/js/deployJava.js"></script> <script> // check if current JRE version is greater than 1.6.0 alert("versioncheck " + deployJava.versionCheck('1.6.0_10+')); if (deployJava.versionCheck('1.6.0_10+') == false) { userInput = confirm( "You need the latest Java(TM) Runtime Environment. " + "Would you like to update now?"); if (userInput == true) { // Set deployJava.returnPage to make sure user comes back to // your web site after installing the JRE deployJava.returnPage = location.href; // Install latest JRE or redirect user to another page to get JRE deployJava.installLatestJRE(); } } </script>
When you specify the minimum version of the JRE software in the 在runApplet
or createWebStartLaunchButton
function, the Deployment Toolkit script makes sure that the required version of the JRE software exists on the client before running your RIA.runApplet
或createWebStartLaunchButton
函数中指定JRE软件的最低版本时,部署工具包脚本会确保在运行RIA之前,客户端上存在所需版本的JRE软件。
Use the 使用runApplet
function to deploy an applet, as shown in the following example. runApplet
函数部署小程序,如下例所示。The last parameter of the runApplet
function is the minimum version that is required to run your applet (version 1.6).runApplet
函数的最后一个参数是运行小程序所需的最低版本(1.6版)。
<script src="https://www.java.com/js/deployJava.js"></script> <script> var attributes = { code:'components.DynamicTreeApplet', width:300, height:300}; var parameters = {jnlp_href: 'dynamictree_applet.jnlp'}; deployJava.runApplet(attributes, parameters, '1.6'); </script>
To deploy a Java Web Start application, use the 要部署Java Web Start应用程序,请使用createWebStartLaunchButton
function with the correct minimum version parameter (version 1.6).createWebStartLaunchButton
函数和正确的最小版本参数(版本1.6)。
<script src="https://www.java.com/js/deployJava.js"></script> <script> var url = "dynamictree_applet.jnlp"; deployJava.createWebStartLaunchButton(url, '1.6.0'); </script>
The runApplet
and createWebStartLaunchButton
functions check the client's version of the JRE software. runApplet
和createWebStartLaunchButton
函数检查客户端的JRE软件版本。If the minimum version is not installed, the functions install the latest version of the JRE software.如果未安装最低版本,功能将安装最新版本的JRE软件。