Detecting Java Version using Javascript??

Hi,
This is a Javascript & Java question really. The problem i have is i want to detect what version of Java a user has.
So using Javascript i can find if java is enabled like so:
navigator.javaEnabled();
but i want to know what version as well.
I tried:
var version = java.lang.System.getProperty("java.version");
but had not luck. does anyone know if this is possible and if so how?
thanks,
Chris.

Because Sun chooses to use a weird format for their version numbers, and since Internet Explorer uses ActiveX objects instead of normal plug-ins, you'd have to write a script that could skim through the Windows registry to dig up what the latest version of the Java Plug-in is.
Scanning through the registry isn't a problem, so much as the non-conventional versioning system that Sun has in place. With Netscape, Opera, and other non-ActiveX browsers, it's a piece of cake.

Similar Messages

  • Detecting java plugin using javascript

    Hello,
    actually I'm neither new to java (but I didn't find a more appropriate forum here) nor my question directly refers to java, instead it concerns javascript:
    I'm looking for a way to detect (inside an html-page) if the java plugin is installed (using javascript). What I don't need/want:
    - Start/use a java applet to check for it (or embed some <object...>-stuff, that probably makes the vm start or opens some dialog automatically)
    - use navigator.javaEnabled() (this merely tells you about the browser settings, not if the plugin is actually installed
    I've already found navigator.plugins to be useful, but this only works on firefox, mozilla etc, but not on IE or Opera.
    Any information or link etc. would be appreciated.
    Thanks.

    I would like to have some script detecting any version of the java plugin (older versions as well).
    Anyway, if you only have a solution for newer versions or some vbscript creating an object... well, I would appreciate if you share it, too. Any help would be just fine :)
    P.S.: About the jws-code you mentioned: I'm new to VBScript. I found something similar I think, but it returns nothing:
    <script>
    function checkPlugin(){
    var r = detectIE("8AD9C840-044E-11D1-B3E9-00805F499D93","java");
    alert("RESULT = " + r);
    function detectIE(ClassID,name){
    result = false;
    alert(ClassID);
    document.writeln('<script language="VBscript">');
    document.writeln('\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))');
    document.writeln('msgbox(IsObject(CreateObject("' + ClassID + '")))');
    document.writeln('</scr' + 'ipt>');
    if (result)
    return name+',';
    else return '';
    </script>Isn't that the way it's supposed to work (the vb is encapsulated to prevent some error messages on the mac, I think)? The classid should be correct, according to the registry.... So, how to do it?

  • Detecting version using javascript or vbscript

    How may I detect JRE version through Javascript or VBScript?

    Because Sun chooses to use a weird format for their version numbers, and since Internet Explorer uses ActiveX objects instead of normal plug-ins, you'd have to write a script that could skim through the Windows registry to dig up what the latest version of the Java Plug-in is.
    Scanning through the registry isn't a problem, so much as the non-conventional versioning system that Sun has in place. With Netscape, Opera, and other non-ActiveX browsers, it's a piece of cake.

  • Finding java version used from compiled code

    Is there a way to find the java version used to compile the java file from the compiled files,i.e., class files?

    that information is encapsulated within the .class file, I don't think so.
    The class file has a minor_version/major_version field.
    However using jikes and sun jdk 1.3.1 both produce a version number of 45.3. According to a footnote in the JVM spec that corresponds to a class file format for java of 1.0.2. And both obviously are newer than that version of java.
    Based on that I don't think one can expect those numbers to changed based on the java version but rather on any changes in the class file itself.

  • Detecting the JVM version using Javascript in IE

    Where can I find the neccessary code to detect the existance and version of the JRE/JVM installed on a client machine. I'm looking for something like this:
    http://java.sun.com/j2se/jre_check/index.jsp
    I'm not a Java programmer, I don't know how to compile a class file. Can someone help? Thanks.

    What you reference is a JavaServerPage served from a server. It doesn't use Javascript.
    You don't give much information; take a look at these search hits and see if anything listed is what you're after. Some of the threads include Javascript code. (But I'm not very knowledgble of its details.) If not, post back with details, maybe someone then would be able to answer.

  • ANSWER: HOW TO DETECT Java Plugin from JavaScript

    I created a new topic because the questions about
    how to detect Java Plugin in browsers are scattered
    thoughout this forum.
    Basically you need to employ two approaches for IE and NS.
    In IE you need to try to instantiate a small applet
    (not your production applet) in order to see if browser
    can do it. if the browser can do it, you can make a
    call applet from JavaScript in order to find version of
    JRE (as well as a host of other things).
    In NS you can write a simple JavaScript which will
    interrogate the browser for all plugins installed. Then
    ypu can make a desicion whether to pass execution to
    the next(or generated) page which hosts your applet,
    or ask the user to download/install a plugin.
    I ecourage everybody to host a plugin on your site
    rather leave default link to it which is generated by
    html converter.
    In order to run sample,
    Prerequisites:
    Java Plugin 1.3.
    If you have a different version of plugin,
    substitute hardcoded plugin version in JavaScript for
    value that you have.
    1. compile java file
    2. put class file in the same directory with html file
    3. load html file into the browser.
    4. press "Check Java Plugin.." button
    5. see it work
    6. examine code
    7. uninstall plugin
    8. repeat steps 1 - 4
    9. see it work
    10. install plugin.
    Sample code follows:
    **********************HTML FILE BEGIN***********
    <HTML>
    <HEAD>
    <!-- Generated by Kawa IDE -->
    <TITLE>Detect Java Runtime</TITLE>
    </HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    var browsername;
    function doNetscape()
    for (i=0; i < navigator.plugins.length; i++)
    for (j = 0; j < navigator.plugins.length; j++)
    if(navigator.plugins[i][j].type == "application/x-java-applet;version=1.3")
    alert("You are running Netscape with Java Plugin 1.3.0 - OK");
    return;
    alert("You are running Netscape\nPlease, install Java Runtime Environment 1.3.0");
    function doMicrosoft()
    var applet = document.myApplet;
    if(applet == null)
    alert("You are running Microsoft Browser.\nPlease, install Java Runtime Environment 1.3.0");
    return;
    var version = applet.getJavaVersion();
    if(version == "1.3.0")
    alert("You are running IE, Java Plugin 1.3.0 installed - OK");
    else
    alert("You are running IE, other plugin installed - mybe OK if later that 1.3.0\nYour version: " + version);
    function getJava()
    var applet = document.myApplet;
    if(applet == null)
    alert("Please, install Java Runtime Environment");
    return;
         alert("JRE Version: " + document.myApplet.getJavaVersion());
    function checkJavaPlugin()
         browsername = navigator.appName;
         if(browsername.indexOf("Netscape")!= -1)
              browsername="NS";
              doNetscape();
         else
              if(browsername.indexOf("Microsoft")!=-1)
                   browsername="MSIE";
                   doMicrosoft();
              else
                   browsername="N/A";
                   alert("Unknown browser: " + browsername);
    </SCRIPT>
    <body>
    <Strong>Check Java Plugin</strong>
    <OBJECT id="myApplet" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
         WIDTH = 1
         HEIGHT = 1 >
         <PARAM NAME = CODE VALUE = "DetectPluginApplet.class" >
         <PARAM NAME="scriptable" VALUE="true" >
         <embed type="application/x-java-applet;version=1.3"
              code = DetectPluginApplet width = 2 height = 2 MAYSCRIPT = "true" >
         </embed>
         </EMBED>
    </object>
    <FORM>
         <INPUT TYPE="button" value="Get Plugin Version in IE" onClick="getJava()">
         <INPUT TYPE="button" value="Check Java Plugin in NS and IE" onClick="javascript:checkJavaPlugin()">
    </FORM>
    </BODY>
    </HTML>
    **********************HTML FILE END***********
    ***************APPLET FILE BEGIN***********
    import java.awt.*;
    public class DetectPluginApplet extends java.applet.Applet
         public void init()
              add(new Label("DetectPluginApplet"));
    public String getJavaVersion()
    return System.getProperty("java.version");
    **************APPLLET FILE END************

    Try following java script, it works on new browsers (NS 4+, IE5+). For IE you have to enable 'ActiveX objects creation' in security options.
    var agt=navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
    && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
    && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.0") !=-1));
    var is_ie5up = (is_ie && (is_major == 4)
    && ( (agt.indexOf("msie 5.0")!=-1)
    || (agt.indexOf("msie 5.5")!=-1)
    || (agt.indexOf("msie 6.0")!=-1) ) );
    var pluginDetected = false;
    var activeXDisabled = false;
    // we can check for plugin existence only when browser is 'is_ie5up' or 'is_nav4up'
    if(is_nav4up) {
    // Refresh 'navigator.plugins' to get newly installed plugins.
    // Use 'navigator.plugins.refresh(false)' to refresh plugins
    // without refreshing open documents (browser windows)
    if(navigator.plugins) {
    navigator.plugins.refresh(false);
    // check for Java plugin in installed plugins
    if(navigator.mimeTypes) {
    for (i=0; i < navigator.mimeTypes.length; i++) {
    if( (navigator.mimeTypes[ i].type != null)
    && (navigator.mimeTypes[ i].type.indexOf(
    "application/x-java-applet;jpi-version=1.3") != -1) ) {
    pluginDetected = true;
    break;
    } else if (is_ie5up) {
    var javaVersion;
    var shell;
    try {
    // Create WSH(WindowsScriptHost) shell, available on Windows only
    shell = new ActiveXObject("WScript.Shell");
    if (shell != null) {
    // Read JRE version from Window Registry
    try {
    javaVersion = shell.regRead("HKEY_LOCAL_MACHINE\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
    } catch(e) {
    // handle exceptions raised by 'shell.regRead(...)' here
    // so that the outer try-catch block would receive only
    // exceptions raised by 'shell = new ActiveXObject(...)'
    } catch(e) {
    // Creating ActiveX controls thru script is disabled
    // in InternetExplorer security options
    // To enable it:
    // a. Go to the 'Tools --> Internet Options' menu
    // b. Select the 'Security' tab
    // c. Select zone (Internet/Intranet)
    // d. Click the 'Custom Level..' button which will display the
    // 'Security Settings' window.
    // e. Enable the option 'Initialize and script ActiveX controls
    // not marked as safe'
    activeXDisabled = true;
    // Check whether we got required (1.3+) Java Plugin
    if ( (javaVersion != null) && (javaVersion.indexOf("1.3") != -1) ) {
    pluginDetected = true;
    if (pluginDetected) {
    // show applet page
    } else if (confirm("Java Plugin 1.3+ not found, Do you want to download it?")) {
    // show install page
    } else {
    // show error page
    }

  • Cannot Change Java Version Using Java Preferences

    When I attempt a change of the current Java version (say, switching from 1.5 to 6) using Java Preferences, the change is reflected in the preferences, but the update does actually occur and java -version continues to report Java 1.5 as the current version.
    If I create another account, this work just fine and I can switch versions at will. Anyone have any idea what might be missing from my account?

    Ok, I figured out what was going on: I had explicitly set my JAVA_HOME in ~/.bash_profile, pointing to the symlinked path for the current JSE. It turns out there a new CLI tool /usr/libexec/java_home that can be used to assign JAVA_HOME like this:
    export JAVAHOME=`/usr/libexec/javahome`
    Using this will ensure that JAVA_HOME is set to the correct value when the shell starts up (if you don't have JAVA_HOME set at all, you can switch the JSE versions in the Terminal 'on-the-fly' when changing the Java Preferences setting).
    http://lists.apple.com/archives/java-dev/2009/Jun/msg00139.html
    Message was edited by: stonehippo

  • Determine Java version with JavaScript

    At my organization there is a Web Application which requires Java 1.4.1_02 installed. The login page is a JSP and we would like to not only determine if the correct version of Java is installed but to have the installation occurr automatically. Is there a JavaScript we could use to perform this service?

    Writing a Web Application that requires Java 1.4.1_02 doesn't mean that you need to ensure that the browsers have this version of Java installed. You'll only need to make sure that Java 1.4 is available on the server.
    The case where you're interested in checking the version of java the browser supports is if the WEb app uses Applets.
    If your Web app does use applets, let the jsp:plugin tag serve up the applet. It will provide the functionality you expect -- prompting the user to download java 1.4 -- without any Javascript, etc. The jsp:plugin tag also helps determine which java platform (IE or Netscape) to download for the browser.

  • How to detect Browser Version using JSP ?

    Hi friends,
    Previously i have asked regarding browser detection.
    Now i want to inquiry regarding version detection.
    I have to block the users other than IE6+.
    So how i do that ??
    Remember : Other than IE6+ users are blocked.
    Please Help Me...

    well in general request.getHeader("user-agent"); should help you but in few cases it may not work in because of few security reasons.
    the best work around for this problem would be usage of javascript and sending browser realted information via hidden parameter
    and here is an example for you
    <body>
    <form name="sampleForm" action="randomAction">
       <input type="hidden" id="browserVersion" name="browserVersion" />
       <input type="hidden" id="userAgentHeader" name="userAgentHeader"/>
         <input type="hidden" id="appCode" name="appCode"/>
    </form>
    <script language="javascript">
      this.document.getElementById('browserVersion').value = navigator.appName+' '+navigator.appVersion;
       this.document.getElementById('userAgentHeader').value = navigator.userAgent;
       this.document.getElementById('appCode').value = navigator.appCodeName;
    </script>
    </body>and you would get the info by getting
    request.getParameter("appCode");and etc..
    hope this might help :)
    REGARDS,
    RaHuL

  • JNI Program to check java version

    Hai,
    I want to write one program to get java version using JNI.ie It should show what version is installed.
    Thanks in Advance

    You do not need JNI to do that:
    see http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#getProperties()
              System.err.println(System.getProperty("java.version"));
              System.err.println(System.getProperty("java.vm.version"));--Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Changing the  Java version in UNIX

    I have a Java version 1.4.2_02 defined in /usr/bin/java.....which is the Java version used by the OS.
    I have installed a higher version in /home/self directory..
    How can I set this as the default Java version to be used by the system?
    Thanks!
    Anand

    Sorry abt this...but I am not tht familiar with
    setting of env variables and settings in UNIX too..
    can u tell me how do I change this variable in
    UNIX...the JAVA_HOME and set it as default for the
    system.
    Thanks!
    AnandNot a UNIX person myself, but this is not a Java-related question at all, but rather an Operating Systems one. You might want to put that kind of question to an appropriate forum elsewhere, or ask classmates/coworkers.
    However, someone may chime in here.

  • Detect and install java runtime environment using javascript

    hi, i'm a flash developer and i only use javascript to embed my movies in html, i've search the web and found some answers but i can't seem to understand it very well maybe because i don't have that much time to learn it. please if you have any script that can detect JRE and install it if it's not installed share it to me. that would be a great help. thanks in advance. :D

    But it is to do with Java and some people here may
    know the answer. I don't know the answer but I would
    like to.Yes some might know the answer, but I think you will find the answer faster if you google, or ask in a javascript forum.

  • Detecting Java Plugin version in IE

    I need to be able to detect the version of the plug-in that is installed in IE. Basically, I want to use an Object tag to load Java 2 in a web browser, but if it's not a compliant version (1.3 version) send the person to an upgrade site. Is this possible using VB/javascript? What is the registered name of the activeX java plugin component?

    While you probably can make some script to determine
    the version of the plug-in, you don't really need to.
    In your HTML, use the OBJECT tags to specify what
    version of the plug-in you require and include the
    URL to redirect to if they do not have it - see
    http://java.sun.com/j2se/1.4.1/docs/guide/plugin/devel
    per_guide/using_tags.html and
    http://java.sun.com/products/plugin/versions.html
    I know about doing this as part of the OBJECT tag. The trouble is that I do not want Ie or the plug-in to try to do the automatic upgrade, and I'd like to be able to redirect the user to my own set of pages describing how to upgrade

  • Using javascript to detect JVM

    Hi all.
    I'm trying to use javascript to detect whether the JVM (either j2sdk or j2ee) has been installed and take the user to SUN web page if not.
    The original MS JVM is not useable for my purposes (does anyone use it?).
    I know how to detect browsers and plug-ins but not JVM.
    Can anyone help out please ?
    TIA :-)

    If you use the classid and codebase attributes of the <object and <embed tags, it will download automatically. Easiest is to use HTMLConverter. You can change codebase to point to somewhere on your network if not everyone has internet access. See [url http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html]here

  • I am trying to use screens and it keeps telling me it cannot detect Java even though I have installed and updated Java?  What might be the problem?

    I am trying to use "screenr" and it keeps telling me it cannot detect Java even though I have downloaded and updated Java?  What is going on or what might I do to correct this?
    Thanks

    Firefox needs 32-bit plugins, so you'll need to install 32-bit Java for Firefox.
    No, you can't change Firefox from 32-bt to 64-bit. There is a Nightly 64-bit version (alpha) of Firefox, but it is used only to test for regressions until development is resumed.

Maybe you are looking for

  • Crystal Reports 10 error while saving report

    Last week i had a problem while saving my report. I get the following error while saving my report: crw32.exe has encountered a problem and needs to close The only way to get around this was after every change build a preview and close the preview an

  • Using iPhone as an apartment callbox number?

    I was just curious if there was a reason you couldn't use iPhone as the apartment call box number? I have it set up as is (I don't have a land line any longer) and the call from the box comes through, but pressing the button doesn't seem to give a su

  • Changing language for a particular user

    Hi How to change language for a particular user in backend system ? Actually i have to get logon language en but automatically it is coming "DE". That is the reason even single sign-on is not wrking from portal for particular user all other users are

  • My Shuffle / Party Shuffle is missing in Itunes

    So i just downloaded my newest version of I-Tunes.. and the Party Shuffle feature is missing from the playlist.  I'm a party shuffle junkie!  How do i recreate it and have it play my entire library randomly. Please help me out. Thank you!!! Michael

  • Applications quitting in 10.4.11

    A friend has a MacMini running 10.4.11. Recently, whenever she tries to open a Microsoft Office 2004 application (Word, Excel) or even Preview, she gets a message box saying "Microsoft Word (or whatever) has quit ..." If she clicks the "Try Again" bu