5

What is the preferred method to determine if the Sun Java Plugin is installed in the browser?

ghempton
  • 7,777
  • 7
  • 48
  • 53

3 Answers3

7

java deployment toolkit


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

if (deployJava.versionCheck('1.6'))
{ 
alert("1.6 installed")
} 

l_39217_l
  • 2,090
  • 1
  • 13
  • 15
  • this doesn't works always. (1) If its disabled in firefox it says not installed. (2) on lion os x, even when its disabled in all browsers, it tells installed – Nakul Aug 28 '11 at 18:11
2

You may also consider PluginDetect script.

Vladimir Grigorov
  • 10,903
  • 8
  • 60
  • 70
0

This isn't an answer for your exact question but is offered as a solution for determining the browser itself. Don't be too harsh, this is really old code that I wrote some time ago.

import java.applet.*;

public class BrowserDetector extends Applet {

    public void init() {
        if (isNetscape()) {
            System.out.println("This browser is a Netscape Browser.");
        }
        if (isMicrosoft()) {
            System.out.println("This browser is a Microsoft Browser.");
        }
        System.out.println("VM Type: " + getVMType());
    }

    public static boolean isNetscape() {
        try {
            Class.forName("netscape.applet.MozillaAppletContext");
        } catch (ClassNotFoundException e) {
            System.out.println("This browser is not a Netscape Browser.");
            return false;
        }
        return true;
    }

    public static boolean isMicrosoft() {
        try {
            Class.forName("com.ms.applet.GenericAppletContext");
        } catch (ClassNotFoundException e) {
            System.out.println("This browser is not a Microsoft Browser.");
            return false;
        }
        return true;
    }

    public String getVMType() {
        String theBrowser = "No VM";
        String appletContext = getAppletContext().toString();
        if (appletContext.startsWith("sun.applet.AppletViewer"))
            theBrowser = "APPLETVIEWER";
        else if (appletContext.startsWith("netscape.applet."))
            theBrowser = "NETSCAPE";
        else if (appletContext.startsWith("com.ms.applet."))
            theBrowser = "MICROSOFT";
        else if (appletContext.startsWith("sunw.hotjava.tags.TagAppletPanel"))
            theBrowser = "HOTJAVA";
        else if (appletContext.startsWith( "sun.plugin.navig.win32.AppletPlugin"))
            theBrowser = "NETSCAPEPLUGIN";
        else if (appletContext.startsWith( "sun.plugin.ocx.ActiveXApplet"))
            theBrowser = "MICROSOFTPLUGIN";
        else if (appletContext.startsWith( "sun.plugin.viewer.context.IExplorerAppletContext"))
            theBrowser = "MICROSOFTPLUGINJRE1.4";

        return theBrowser;
    }

}
Paul Gregoire
  • 9,715
  • 11
  • 67
  • 131