Documentation

The Java™ Tutorials
Hide TOC
Deploying an Applet部署小程序
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Toolkit

Deploying an Applet部署小程序

You can deploy applets by using the runApplet function of the Deployment Toolkit script. 可以使用部署工具包脚本的runApplet函数部署小程序The runApplet function ensures that the required minimum version of the Java Runtime Environment (JRE) software exists on the client and then runs the applet. runApplet函数确保客户端上存在所需的Java运行时环境(JRE)软件的最低版本,然后运行小程序。The runApplet function generates an HTML <applet> tag with the information provided.runApplet函数生成一个带有所提供信息的HTML<applet>标记。


Note: Depending on the type of browser, you might be unable to view the HTML generated by the Deployment Toolkit script when you try to view the source for the web page. 根据浏览器的类型,在尝试查看网页的源代码时,可能无法查看部署工具包脚本生成的HTML。To view the generated HTML, try saving the HTML page after it has been loaded, or use a tool such as Firebug (a Mozilla Firefox add-on).要查看生成的HTML,请尝试在加载HTML页面后保存该页面,或者使用Firebug(Mozilla Firefox插件)等工具。

You can deploy applets by specifying the deployment options as attributes and parameters of the <applet> tag. 通过将部署选项指定为<applet>标记的属性和参数,可以部署applet。You can also specify deployment options in a Java Network Launch Protocol (JNLP) file to take advantage of advanced features. 您还可以在Java网络启动协议(JNLP)文件中指定部署选项,以利用高级功能。See the Java Network Launch Protocol topic for more information about this protocol.有关该协议的更多信息,请参阅Java网络启动协议主题


Note: 

If the client does not have the required minimum version of the JRE software, the Deployment Toolkit script redirects the browser to http://www.java.com to allow users to download the latest JRE software. 如果客户端没有所需的JRE软件最低版本,部署工具包脚本会将浏览器重定向到http://www.java.com以允许用户下载最新的JRE软件。On some platforms, users might be redirected before they can view the web page containing the applet.在某些平台上,用户在查看包含小程序的网页之前可能会被重定向。


The parameters to the runApplet function vary depending on whether you are using JNLP. runApplet函数的参数根据您是否使用JNLP而有所不同。Applets deployed by using JNLP can run only if the next generation Java Plug-in software exists on the client machine (the next generation Java Plug-in software was introduced in the Java Platform, Standard Edition 6 update 10 release).使用JNLP部署的小程序只有在客户机上存在下一代Java插件软件时才能运行(下一代Java插件软件是在Java平台的Standard Edition 6 update 10发行版中引入的)。

The next section shows how to use the runApplet function in the HTML page that will display the applet. 下一节将展示如何在显示小程序的HTML页面中使用runApplet函数。The following usage scenarios are described:描述了以下使用场景:

Function signature:函数签名: runApplet: function(attributes, parameters, minimumVersion)

Parameters:参数:

Usage:用法:

The following guidelines are helpful if some deployment options have different values in the attribute name-value pairs and in the JNLP file:如果某些部署选项在属性名称-值对和JNLP文件中具有不同的值,则以下指导原则非常有用:

Open DeployUsingNameValuePairsAndJNLP.html in a browser to view the Java2D applet.在浏览器中打开DeployUsingNameValuePairsAndJNLP.html以查看Java2D小程序。


Note:  If you don't see the applet running, you need to install at least the Java SE Development Kit (JDK) 7 release.如果没有看到小程序运行,则至少需要安装JavaSE开发工具包(JDK)7版本。

Download source code for the Run Applet example to experiment further.下载Run Applet示例的源代码以进行进一步实验。


Previous page: Deployment Toolkit
Next page: Embedding JNLP File in Applet Tag