There are many reasons to check if a particular version of the Java Runtime Environment (JRE) software is available on a client machine. 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.
Use the Deployment Toolkit script's versionCheck
function to check if a particular version or range of JRE versions is installed on the client.
Function signature: versionCheck: function(versionPattern)
Parameters:
versionPattern
– String specifying the version or range of versions to check for, such as such as "1.4", "1.5.0*" (1.5.x family), and "1.6.0_02+" (any version greater than or equal to 1.6.0_02).Usage: Creating a different user experience depending on the client's JRE software version
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. If not, the browser is redirect them to java.sun.com
.
<script src="http://www.java.com/js/deployJava.js"></script> <script> if (deployJava.versionCheck('1.6+')) { var url = "http://java.sun.com/javase/technologies/desktop/javawebstart/apps/notepad.jnlp"; deployJava.createWebStartLaunchButton(url, '1.6.0'); <!-- you can also invoke deployJava.runApplet here --> } else { document.location.href="http://java.sun.com"; } </script>
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).