Documentation

The Java™ Tutorials
Hide TOC
Checking the Client JRE Software Version检查客户端JRE软件版本
Trail: Deployment
Lesson: Deployment In-Depth
Section: Deployment Toolkit

Checking the Client JRE Software Version检查客户端JRE软件版本

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:参数:

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>

Note: Depending on the client's operating system and version of the Java platform, you might be able to verify version information for JRE software at the major version level (for example, 1.6) or at a finer update level (for example, 1.6.0_10). 根据客户机的操作系统和Java平台的版本,您可能能够在主要版本级别(例如,1.6)或更精细的更新级别(例如,1.6.0_10)上验证JRE软件的版本信息。

Previous page: Deploying Without Codebase
Next page: Java Network Launch Protocol