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发行说明。
Beginning in the Java SE 7 release, you do not have to specify an absolute path for the 从Java SE 7版本开始,您不必在Java Web Start应用程序的Java Network Launch Protocol(JNLP)文件中为codebase
attribute in the Java Web Start application's Java Network Launch Protocol (JNLP) file. codebase
属性指定绝对路径。You can develop and test your applications in different environments without having to modify the path in the 您可以在不同的环境中开发和测试应用程序,而无需修改codebase
attribute. codebase
属性中的路径。If no codebase is specified, the Java Web Start software assumes that the codebase is relative to the web page from which the Java Web Start application is launched.如果未指定代码库,Java Web Start软件会假定代码库与启动Java Web Start应用程序的网页相关。
The following functions of the Deployment Toolkit script can be used to deploy Java Web Start applications in a web page when the JNLP file does not contain the 当JNLP文件不包含codebase
attribute:codebase
属性时,可以使用部署工具包脚本的以下功能在网页中部署Java Web Start应用程序:
launchWebStartApplication
– createWebStartLaunchButtonEx
– Function signature:函数签名: launchWebStartApplication: function(jnlp)
Parameter:参数:
jnlp
– The path to the JNLP file containing deployment information for the Java Web Start application. 包含Java Web Start应用程序部署信息的JNLP文件的路径。This path can be relative to the web page in which the Java Web Start application is deployed.此路径可以相对于部署Java web Start应用程序的网页。
Usage:用法:
In the following example, the 在以下示例中,在HTML锚定(launchWebStartApplication
function is invoked in the href
attribute of an HTML anchor (a)
tag.a
)标记的href
属性中调用launchWebStartApplication
函数。
The dynamictree_webstart_no_codebase.jnlp
JNLP file is used to deploy the Dynamic Tree Demo application.dynamictree_webstart_no_codebase.jnlp
JNLP文件用于部署动态树演示应用程序。
<script src="https://www.java.com/js/deployJava.js"></script> <a href="javascript:deployJava.launchWebStartApplication('dynamictree_webstart_no_codebase.jnlp');">Launch</a>
The Java Web Start application is launched when the user clicks the resulting HTML link.当用户单击生成的HTML链接时,会启动Java Web Start应用程序。
Function signature:函数签名 createWebStartLaunchButtonEx: function(jnlp)
Parameter:参数:
jnlp
– The path to the JNLP file containing deployment information for the Java Web Start application. 包含Java Web Start应用程序部署信息的JNLP文件的路径。This path can be relative to the web page in which the Java Web Start application is deployed.此路径可以相对于部署Java web Start应用程序的网页。
Usage:用法:
The following example shows the usage of the 以下示例显示createWebStartLaunchButtonEx
function.createWebStartLaunchButtonEx
函数的用法。
The
JNLP file is used to deploy the Dynamic Tree Demo application.dynamictree_webstart_no_codebase.jnlp
JNLP文件用于部署动态树演示应用程序。dynamictree_webstart_no_codebase.jnlp
<script src="https://www.java.com/js/deployJava.js"></script> <script> var jnlpFile = "dynamictree_webstart_no_codebase.jnlp"; deployJava.createWebStartLaunchButtonEx(jnlpFile); </script>
The Java Web Start application is launched when the user clicks the resulting Launch button.当用户单击生成的启动按钮时,将启动Java Web Start应用程序。
Open 在浏览器中打开JavaWebStartAppPage_No_Codebase.html
in a browser to view the Dynamic Tree Demo application that is deployed by using the functions described in this topic.JavaWebStartAppPage_No_Codebase.html
,查看使用本主题中描述的功能部署的动态树演示应用程序。
You can also launch the Java Web Start application at the system command prompt by invoking the 您还可以在系统命令提示符下启动Java Web Start应用程序,方法是使用JNLP文件的完整url调用javaws
command with the complete url of the JNLP file as shown in the following code snippet.javaws
命令,如以下代码段所示。
javaws http://example.com/dynamictree_webstart_no_codebase.jnlp
Download source code for the Dynamic Tree Demo example to experiment further.