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
}

Similar Messages

  • How to call java program from javascript

    Hi,
    I have an java program which will transform one xml to another xml using XSLT.
    I want to call this java program from Javascript? Is this possible? Please suggest me.
    Thanks,
    Gopal

    is it not possible?
    do i have to refresh the page and read in the values like...
    <%
    String ename = request.getParameter( "EmployeeName");
         session.setAttribute( "ename", ename);
    %>and then call the class from here?
    looking around ive come across ajax but i dont know how to use it and what you need to install and if its compatable with tomcat and jsp?
    is ajax better or not really worth it?
    i have anything up to 100 fields that need saving at one save click

  • 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?

  • How to call java classes from javascript?

    i have a button which calls javascript i need to access a class to update the values in the database.. how do you call the java code from within the javascript?
    the class is stored under tomcats classes directory and is accessed:
    com.Database.Employee
    the method is called : UpdateEmployeeDetails
    the button
    <input type="button" value="Save" onclick="submitForm('save')" />the javascript
    <script language="javascript">
            function submitForm(process){    
                document.myForm.action="update.jsp";
                document.myForm.submit();
    </script>

    is it not possible?
    do i have to refresh the page and read in the values like...
    <%
    String ename = request.getParameter( "EmployeeName");
         session.setAttribute( "ename", ename);
    %>and then call the class from here?
    looking around ive come across ajax but i dont know how to use it and what you need to install and if its compatable with tomcat and jsp?
    is ajax better or not really worth it?
    i have anything up to 100 fields that need saving at one save click

  • How to terminate java process from javascript

    How can we terminate architecture flow in between of process ? suppose once we have submitted form to insert the record but we want to terminate the process started at java side before inserting record in database, how is it possible through javascript?

    The thing is I wish to terminate the current java process when user clicks on any other action on jsp page. I am calling these process from ajax. when user click any other action on the page I abort the current XMLHttpRequest but only the request on the page stop but the process on java side don't stop exetuting

  • How to control PDF plugin from Javascript?

    I need to embed a PDF viewer into a webpage displayed on a special infokiosk withou a keyboard and a mouse. The infokiosk will have just five control button (four arrows and an OK button), which will map to corresponding keys on keyboard. It will be running a simple Linux system and Firefox browser as GUI.
    This is exactly what I need to accomplish:
    http://pdftools.atwebpages.com/embedPDF.html
    However, it works only in Internet Explorer. I need this very functionality in Firefox on Linux. I have not been able to come accross any documentation telling me, how to do it. On the other hand I have found:
    http://www.adobe.com/devnet/acrobat/interapplication.html
    which mentions Windows and Macintosh, but does not mention Linux at all. Does this mena that I will not be able to control PDF viewer with Javascript under Firefox/Linux?

    I need to embed a PDF viewer into a webpage displayed on a special infokiosk withou a keyboard and a mouse. The infokiosk will have just five control button (four arrows and an OK button), which will map to corresponding keys on keyboard. It will be running a simple Linux system and Firefox browser as GUI.
    This is exactly what I need to accomplish:
    http://pdftools.atwebpages.com/embedPDF.html
    However, it works only in Internet Explorer. I need this very functionality in Firefox on Linux. I have not been able to come accross any documentation telling me, how to do it. On the other hand I have found:
    http://www.adobe.com/devnet/acrobat/interapplication.html
    which mentions Windows and Macintosh, but does not mention Linux at all. Does this mena that I will not be able to control PDF viewer with Javascript under Firefox/Linux?

  • How to call java function in javascript

    Hello Everyone,
    Can anyone tell me solution that:
    How to call java function in javascript?
    Thanks,
    VIDs

    You can't since Java is running on the server and javascript is running in the browser long after the Java side of things has finished executing. Assuming you're not talking about an applet here.
    But you can make calls back to the server through Ajax. All you need is something like a servlet on the receiving end which you can invoke through Ajax; from that point you can execute any Java code you want.

  • How to uninstall java plugin without removing JRE completely

    how to uninstall java plugin without removing JRE completely.
    Hope someonce can help, all the documentation ive seen till now shows how to uninstall the Java plugin by completely removing the JRE.
    Also if you install JRE 1.4.1_01 and do not choose to install the browser plugin on the browers prompted ... does it not install the plugin?

    In IE
    Tools -> Internet Options -> Settings -> View Objects
    Delete the ActiveX control for the Java Plugin
    This removes the ActiveX control (plug-in) from the browser but doesn't delete the JRE.

  • Access Java object from Javascript

    Hi
    I'm trying to invoke a Java object from Javascript (scriptengine and all that).
    I want to add scripting features to a GeneXus Java generated app... and I have very basic skills on java too. Sorry for that ;o).
    This is the java code to pass "params" to the scriptengine:
    engine.put("remoteHandle",remoteHandle);
    engine.put("context", context); The remoteHandle (int) and context (com.genexus.ModelContext) pass trough all the gx-java generated programs.
    This javascript works fine:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle).execute( ) ;The remoteHandle conversion is ok (javascript-number to int). The context is optional.
    But if I want to pass context:
    importClass(Packages.uftestjs);
    new uftestjs(remoteHandle, context).execute( ) ;Fails with this:
    "javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Java constructor for 'uftestjs' with arguments 'number,javax.script.SimpleScriptContext' not found."
    Obviously, no conversion is possible with context (javax.script.SimpleScriptContext to com.genexus.ModelContext).
    There is some way to reference de original context, by the object Id??? or something like that???
    Thanks in advance for any replies!!!
    Greetings from Chile. (I hope you can understand my english!)

    Hi
    Well, since this topic is about java programming I think the place is right here.
    (I use some tricks to embed java statements in genexus objects...)
    I will try to get some help at Artech (GX) on how to build something... to get the conversion needed.
    But they are not focussed on support this kind of questions.
    Anyway, I want to know: do I can to reference an object by the objId?
    I want to code something like this:
    com.genexus.ModelContext context =
                     (com.genexus.ModelContex)getTheObjectFromTheJVM(theObjectId);(powered by google translator, ha!)

  • How to call SOAP API from JavaScript

    Hi,
    I'm trying to call the SOAP API to get statistics about emails. Are there any examples on how to call the API from JavaScript?
    Here is a link to my original question about using the REST API. REST API URL for email statistics
    Thanks,
    Tim

    Tim,
    In order to consume a SOAP API I recommend you use something other than JavaScript.
    Any platform can offer you a good SOAP client should be OK. (.Net, Java, php, Ruby, python).
    I didn't see anyone successfully used javascript and consume the Eloqua SOAP API.
    I know you can create a SOAP client in Java script but it will be too much work to handle the Eloqua response in some cases.
    Regards,
    Daniel

  • How to call  java program from ABAP

    Hi Experts,
         My requirement is to call java programs from ABAP. For that i have set up SAP JCO connection by using this link http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/739. [original link is broken] [original link is broken] [original link is broken] Connection gets sucessfully. After this how to call java program from ABAP as per our requirement. Please help me out.
      Also i tried this way also.. but while executing the DOS Command line appear & disappear in few seconds. So couldnt see the JAVA output. Please help me out to call java programs in ABAP..
    DATA:command TYPE string VALUE 'D:Javajdk1.6.0_20 injavac',
    parameter TYPE string VALUE 'D:java MyFirstProgram'.
    CALL METHOD cl_gui_frontend_services=>execute
    EXPORTING
    application = command
    parameter = parameter
    OPERATION = 'OPEN'
    EXCEPTIONS
    cntl_error = 1
    error_no_gui = 2
    bad_parameter = 3
    file_not_found = 4
    path_not_found = 5
    file_extension_unknown = 6
    error_execute_failed = 7
    OTHERS = 8.
    Thanks.

    This depends on the version of your Netweaver Java AS. If you are running 7.0, you will have to use the Jco framework. The Jco framework is deprecated since 7.1 though. If you want to build a RFC server in 7.1 or higher, it is adviced that you set it up through JRA.
    Implement an RFC server in 7.0:
    http://help.sap.com/saphelp_nw04/helpdata/en/6a/82343ecc7f892ee10000000a114084/frameset.htm
    Implement an RFC server in 7.1 or higher:
    http://help.sap.com/saphelp_nwce72/helpdata/en/43/fd063b1f497063e10000000a1553f6/frameset.htm

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to download java plugin for safari browser of my ipad

    How to download  java plugin for my safari browser of iPad..

    Welcome to Apple Support Communities
    I'm sorry, but Java isn't compatible with the iPad

  • How to call java method from workflow script?

    Hi
    I have a requirement of updating field value 'Document Status' based on review/approve of content from Workflow and hence need to update the version number. For that I need to call my java method from workflow during submit of review/approve condition. Please let me know how to call java method from workflow?
    Is there any alternative better way to achive this requirement from workflow? Please suggest.
    Thanks,
    Sarang

    OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
    Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
    If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
    Solved?

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

Maybe you are looking for

  • What is BEST Tool to convert WMV to SWF?.

    I need to convert many wmv to swf. Which tool is best?. Any open source tool available?. If not, we can buy best tool.

  • Any way color overlay could be carried over from psd to Reflow?

    Hello, We are really excited about Edge Reflow in the office, but one pain is that layer effects in the psd don't carry over to the Reflow file. A lot of times we designers use color overlay on things like copy in various parts of the layout to see d

  • Question About Oracle in general

    Hi everyone... Well, I took a course in ORACLE, SQL,PLSQL,Developer and Reports...And thinking of making the ORACLE certified exams soon. And I'm still in the Uni. till now studying computer science... But I'm thinking to start asking about what can

  • SOA 11.1.1.5 Error on insert to table

    Hi Need hlep!! We are getting the following error in the SOA composite when we try to insert to table <fault> <bpelFault> <faultType>0</faultType> <remoteFault> <part name="summary"> <summary>oracle.fabric.common.FabricInvocationException: java.lang.

  • Regarding Syn-Asyn Bridge

    Hi All, Can any one explain the following:- In Syn-Asy bridge, we are using Reveiver Step( open Syn/Asyn), Send step(Asyn), Receiver step(Asyn), Sendstep(close syn/Asyn bridge). In this case receiver is Asynchronous system, so we are taking response