Skip to main content

What version of Java are you running?

Posted by malcolmdavis on March 27, 2010 at 2:51 PM PDT

There can be issues promoting Java applications over the Internet. There are various versions of Windows and Windows Server that run pre-6 Java, or even Microsoft Java Virtual Machine.

Verifying the version of Java on someone machine is a good way of eliminating a potential problem.

Michael Horowitz sponsors the embedded applet approach at http://www.javatester.org/version.html

However, there are several issues with the embedded applet approach. One problem deals with the IE 8 browser. IE is still not entirely Java friendly, IE sometimes just decides to play dead when loading a page with a Java applet.

Sun/Oracle provides a Deployment Toolkit Script called deployJava.js. More about the deployJava.js script and usage can be found at: http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advic...

deployJava.js is used for other things such as enhancing google analytics tracking of Java: http://cowwoc.blogspot.com/2008/12/tracking-java-versions-using-google.html

 

The following script will check and see if the proper version of Java is installed and will display a message if not the proper version is not installed.

 <html>

<head>

      <script src="http://java.com/js/deployJava.js"></script>

</head>

<body>

<div id="dcontent" style="width:100%; background-color: #E2E2FC; padding-left: 5px"></div>



<script type="text/javascript">

deployJava.do_initialize();

var java_message =' <p><h2>Product XYZ requires Java</h2><p>Invalid version of Java.   XYZ  requires Java 7 or higher.   You can download and install Java from <a target="_blank" href="http://java.com">www.java.com</a></p>'

function altercontent(){

    if( deployJava.versionCheck("1.7")==false ) {

        if (document.all) {

            dcontent.innerHTML=java_message;

        } else if (document.getElementById){

            rng = document.createRange();

            el = document.getElementById("dcontent");

            rng.setStartBefore(el);

            htmlFrag = rng.createContextualFragment(java_message);

            while (el.hasChildNodes()) {

                el.removeChild(el.lastChild);

            }

            el.appendChild(htmlFrag);}

    }

}

window.onload=altercontent

</script>

</body>

</html>

 

Sample

A future message for Java 7:

 

 

 

Related Topics >>