Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 839
all versions
How To: Write an applet to detect the version and vendor the of the JVM (Java Virtual Machine) you are running.

Microsoft and Sun have slightly differing implementations of the JVM browser plug in. Additionally, Internet Explorer can be configured to use either the Sun or Microsoft JVM, so knowing which browser is being used is not enough information to determine the JVM vendor.

Having access to the version and vendor information of the JVM can help you branch your JFile code in the event that an implementation difference between vendors or versions affects the behavior of JFile. Javascript can only be used to return the version number of the JVM for Netscape. To determine the vendor and version of the JVM in both Internet Explorer and Netscape, you must use a java applet. This KB article will provide you with the Java code necessary for JVM vendor and version detection.

The following Java code can be used to create an applet that can be used to determine the version and vendor of the JVM that is running in the browser. The applet has public methods available so that you can script against the applet and have the vendor and version values returned to your client scripting environment. The Java Code:

 import java.applet.*;

 public class JavaVersionDisplayApplet extends Applet
    private String m_ver;
    private String m_ven;

    public JavaVersionDisplayApplet()
      m_ver = System.getProperty("java.version");
      m_ven = System.getProperty("java.vendor");

    public String getVersion()
      return m_ver;

    public String getVendor()
      return m_ven;

Scripting Against the Applet:

 <SCRIPT language="JavaScript">
 function showJVMDetails()
    var app = document.applets[0];
    var version = app.getVersion();
    var vendor = app.getVendor();
    window.alert("Version: " + version + "\nVendor: " + vendor);
 <INPUT type="button" onclick="showJVMDetails();"
    id="Button1" name="Button1"
    value="clickto show vendor and version of the browser JVM">
 <APPLET codeBase="." height="0" width="0"
    code="JavaVersionDisplayApplet.class" name="display"
    mayscript VIEWASTEXT>

The above code simply refers to the compiled Java class that is available with the source code as an attachment to this KB article. It is advisable for you to create signed cab and jar files for distribution of your applet, so that your application users can be certain of the safety of your code. The JFile documentation provides instructions for getting started with signing an applet: http://support.softartisans.com/docs/JFile/install_signapplet.htm
Created : 5/13/2004 1:43:12 PM (last modified : 5/13/2004 1:43:12 PM)
Rate this article!