Question

I wanted to get the Java Vendor and Version info.

Recently i installed java 1.7.0.7 in mac mountain lion and document.MyApplet.getJavaVendor() Throws exception (type error 'undefined' is not a function) when i run my below HTML file as mentioned below in safari 6.

But the same works fine with java 1.6.0.35.

Till the applet is not loaded it will throw the exception as mentioned above but once the applet is loaded it should get the info as expected.

Additional Info: I even tried to do the same with Firefox, there its working absolutely fine with both the JRE's.

Applet HTML code:

<applet name="MyApplet" codebase = "./code/" archive="MyApplet.jar" code="MyApplet.class" width="1" height="1" style="border-width:0;" MAYSCRIPT=true>
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"/>
    <PARAM NAME="cache_option" VALUE="plugin"/>
    <PARAM NAME="cache_archive" VALUE="MyApplet.jar"/>
    <PARAM NAME="cache_version" VALUE="5.6.3.1"/>
    <PARAM NAME="scriptable" VALUE="true"/>
    <PARAM name="codebase_lookup" value="false"/>
</applet>

Java script code:

function verifyJRE() {

    try {
        var tmpVendor = document.MyApplet.getJavaVendor();
        var tmpVersion = document.MyApplet.getJavaVersion();

        var strJavaVendor = new String( tmpVendor);
        var strJavaVersion = new String( tmpVersion);

        if ( (strJavaVendor.indexOf("Apple") != -1) || (strJavaVendor.indexOf("Sun") != -1) || (strJavaVendor.indexOf("Oracle") != -1)) {
             // Do something;
        } else {
             // Do Something;                   }
    } catch (e) {
        iCount++;
        if (iCount < 10)
             // waiting for Applet to Load;
             setTimeout('verifyJRE()', 200);
        else {
             // logout from application;
    }
}

Applet Code:

import java.applet.Applet;
import java.io.PrintStream;


public class MyApplet extends java.applet.Applet {

    private String strJavaVendor;
    private String strJavaVersion;

    public MyApplet() {
    }    

    public void init() {
        strJavaVendor = System.getProperty("java.vendor");
        strJavaVersion = System.getProperty("java.version");
    }

    public String getJavaVendor() {
        System.out.println(new StringBuilder("Java Vendor is: ").append(strJavaVendor).toString());
        return strJavaVendor;
    }

    public String getJavaVersion() {
        System.out.println(new StringBuilder("Java Version is: ").append(strJavaVersion).toString());
        return strJavaVersion;
    }
}

Could someone help me with this issue?

Was it helpful?

Solution

Issue got Resolved with Apple OSX 10.8.2 and Safari 6.0.1 Update

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top