This discussion is archived
5 Replies Latest reply: Jan 2, 2013 1:25 PM by 818043 RSS

How does deployJava.versionCheck work?

818043 Newbie
Currently Being Moderated
To check the version of JRE on the Windows client, the script "if (deployJava.versionCheck('1.x'))" is used.

For example,
if (deployJava.versionCheck('1.6+'))
checks if the JRE software on the client is 1.6 or higher.

Does anyone know exactly what this script is looking at on the desktop to determine the version of JRE installed? For example, does it check the registry?
If not, what?

Thanks!

Edited by: 815040 on Jan 2, 2013 12:44 PM

Edited by: 815040 on Jan 2, 2013 1:04 PM

Edited by: 815040 on Jan 2, 2013 1:13 PM

Edited by: 815040 on Jan 2, 2013 1:30 PM

Edited by: 815040 on Jan 2, 2013 1:45 PM
  • 1. Re: How does deployJava.versionCheck work?
    RogerL (Oracle) Java Champion
    Currently Being Moderated
    It is JavaScript. It does not touch the registry.
    Here is text version of the script: https://www.java.com/js/deployJava.txt (https://www.java.com/js/deployJava.js)

    How it determines the JRE version is based on the browser. Have a look at the script.

    A couple URLS:
    http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html
    http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/deployment_advice.html
    http://docs.oracle.com/javase/tutorial/deployment/deploymentInDepth/ensuringJRE.html


    -Roger
  • 2. Re: How does deployJava.versionCheck work?
    gimbal2 Guru
    Currently Being Moderated
    Its Javascript, so no it cannot do things like check the registry. It would be terrible if such things were possible from a browser scripting language.

    You can always investigate the source yourself, but I believe it does a DHTML trick to try and render the version check applet on the java.com website. That applet returns the necessary runtime information to validate the conditions you specify.

    EDIT: ninja'd by dr. Oracle himself!
  • 3. Re: How does deployJava.versionCheck work?
    818043 Newbie
    Currently Being Moderated
    Thanks for the reply. I know nothing about JavaScript, but it looks like deployJava.versionCheck causes another function, getJREs() to execute, and that function returns the version(s) of Java JRE installed on the computer. Any ideas as to where getJREs() gets the information about what version of JRE is installed?
  • 4. Re: How does deployJava.versionCheck work?
    RogerL (Oracle) Java Champion
    Currently Being Moderated
    Again, it depends. There is lots of code in that file because of all the variations with browsers, the versions of Java.... there is no easy single answer.

    Here is method for FF:
        // obtain JPI version using navigator.mimeTypes array
        // if found, set the version to this.firefoxJavaVersion
        getJPIVersionUsingMimeType: function() {
            // Walk through the full list of mime types.
            for (var i = 0; i < navigator.mimeTypes.length; ++i) {
                var s = navigator.mimeTypes.type;
    // The jpi-version is the plug-in version. This is the best
    // version to use.
    var m = s.match(/^application\/x-java-applet;jpi-version=(.*)$/);
    if (m != null) {
    this.firefoxJavaVersion = m[1];
    // Opera puts the latest sun JRE last not first
    if ('Opera' != this.browserName2) {
    break;
    Don't know much about mimeType Arrays myself, Google is helpful though:
    http://www.w3resource.com/javascript/client-object-property-method/navigator-mimeTypes.php
    https://developer.mozilla.org/en-US/docs/DOM/window.navigator
    
    I suspect you are seeing some error or problem, which is why the question was first asked. If so, what is not working, or not working as expected? 
    
    -Roger
    not a ninja or a doctor :)
    
    Edited by: EJP on 3/01/2013 08:55: added code tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
  • 5. Re: How does deployJava.versionCheck work?
    818043 Newbie
    Currently Being Moderated
    One of the websites in my company uses the deployJava.versionCheck function to display the version of Java JRE present on the computer, and I was curious as to exactly how that function determined what version of Java is installed. I'll dig into it further with all of the information you gave me. Thanks again!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points