文档

Java™ 教程-Java Tutorials 中文版
部署 Applet
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Toolkit

部署 Applet

You can deploy applets by using the runApplet function of the Deployment Toolkit script. 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. The runApplet function generates an HTML <applet> tag with the information provided.


注意: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. 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).

You can deploy applets by specifying the deployment options as attributes and parameters of the <applet> tag. You can also specify deployment options in a Java Network Launch Protocol (JNLP) file to take advantage of advanced features. See the Java Network Launch Protocol topic for more information about this protocol.


注意: 

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. 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. 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).

The next section shows how to use the runApplet function in the HTML page that will display the applet. 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:

Open DeployUsingNameValuePairsAndJNLP.html in a browser to view the the Java2D applet.


注意:如果你没有看到 applet 正在运行,则需要至少安装 Java SE Development Kit (JDK) 7 版本。

Download source codefor the Run Applet example to experiment further.


Previous page: Deployment Toolkit
Next page: Customizing the Loading Screen