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发行说明。
There are many reasons to check if a particular version of the Java Runtime Environment (JRE) software is available on a client machine. 有很多原因需要检查客户机上是否有特定版本的Java Runtime Environment(JRE)软件。For example, you might want to launch a different version of your rich Internet application (RIA) or redirect the user to a different page depending on the client's JRE software version.例如,您可能希望启动不同版本的富互联网应用程序(RIA),或者根据客户端的JRE软件版本将用户重定向到不同的页面。
Use the Deployment Toolkit script's 使用部署工具包脚本的versionCheck
function to check if a particular version or range of JRE versions is installed on the client.versionCheck
函数检查客户端上是否安装了特定版本或范围的JRE版本。
Function signature:函数签名: versionCheck: function(versionPattern)
Parameters:参数:
versionPattern
– Usage:用法: Creating a different user experience depending on the client's JRE software version根据客户的JRE软件版本创建不同的用户体验
In this example, a Launch button is created for the Notepad application only if the version of JRE software on the client is greater than or equal to 1.6. 在本例中,仅当客户端上的JRE软件版本大于或等于1.6时,才会为记事本应用程序创建启动按钮。If not, the browser is redirected to 如果没有,浏览器将重定向到oracle.com
.oracle.com
。
<script src="https://www.java.com/js/deployJava.js"></script> <script> if (deployJava.versionCheck('1.6+')) { var url = "https://docs.oracle.com/javase/tutorialJWS/deployment/webstart/examples/Notepad.jnlp"; <!-- you can also invoke deployJava.runApplet here --> deployJava.createWebStartLaunchButton(url, '1.6.0'); } else { document.location.href="http://oracle.com"; } </script>