About Java and Java version detection


What is Java?

Java was introduced by Sun Microsystems in 1995 and is generally understood to be the most popular general-purpose computing language in use today for interactive possibilities on the web. Java is a beautiful programming language, strictly object oriented, expressive and elegant. It has an always-already cross-platform orientation that lives up to its slogan "write once - run anywhere".

Until Microsoft had a falling out with Sun, Java was bundled with Windows by default and was loaded at start up. Today Java is a separate download and not loaded for use by a web browser until called. But once loaded, Java applications take next to no time to get underway.

What can Java do?

Java is independent of platform and can run from anywhere. It is used server side, client side and even used in mobile phones for a vast variety of applications performing complex database manipulation, interactive games and visual.

What can Java not do?

Web browsers impose the following restrictions on any applet loaded over the network:

  • An applet cannot load libraries or define native methods.

  • Java cannot ordinarily read or write files on the host that is executing it.

  • Java cannot make network connections except to the host that it came from.

  • Java cannot start any program on the host that is executing it.

  • Java cannot read certain system properties.

Java is one of the safest languages available and cannot harm computer files.

What if Java is disabled?

If Java is disabled then CopySafe Web encrypted images will not be visible to Mac and Linux users. CopySafe Web images for those browsers are displayed in a Java security applet that decrypts the images before they can be displayed on the web page. Without decryption no image can be visible and the image remains secure.

How to detect Java?

If Java is not installed or not enabled for use in a web browser, the visitor needs to be redirected for advice and/or download. JavaScript an be used to detect Java however the result is not reliable for all web browser types. Also, version needs to be detected because some browsers have older versions of Java and version 1.4 or later is required to view CopySafe Web security applets.

The most reliable detection method for Java version, one that will run from any web page and work for all web browser types, is using the Java Version Applet by Andrew Thompson. Then all you need is the JavaScript for your page header:

<SCRIPT>
<!--
// edit to suit version and Java download
var minversion = "1.4";
var javadownload = "http://www.java.com";

function showerror()
{
window.alert("Java version " + minversion + " or later is required to view this page!\n\nIf java is installed it needs to be enabled.\n\nOr you can get the latest version from www.java.com");
document.location.href = javadownload;
}
function showJVMDetails()
{
var undefined;
var app = document.applets[0];
var version3 = app.getVersion();
var version = (version3.substr(0,3));
if ((version*1) < (minversion*1))
{
window.alert("Java version " + minversion + " or later is required to view this page!\n\nYou can get the latest version from www.java.com");
document.location.href = javadownload;
}
}
window.onerror = showerror;
// -->
</SCRIPT>

Then add an onload statement to your BODY tag and the applet code just below:

<BODY onload="showJVMDetails();">

<APPLET height="0" width="0" code="JavaVersionDisplayApplet.class" name="display">
</APPLET>

If your visitor has Java version less than 1.4 they will be redirected to java.com for download. If they Java disabled, they will get the hint.

Return to top

facebook
twitter
email