Determine if java client browser is installed and can run applets

I am developing a .aspx page that will eventually launch the applet after the user clicks the button (I use the <applet> ). Therefore, I would like to know if java is / is enabled in the user's browser.

I am using the navigator.javaEnabled () method. However, despite the fact that this works fine on IE7, it returns inconsistent results in Firefox 3.0.12 (I don’t know about different browsers), sometimes saying that java is turned on (this is it), and then after running the applet and will return from again applet to this page, it will report an error. If I close firefox and return to the applet launch page, navigator.javaEnabled () will again return true (correctly).

Is there something that defines this inconsistent behavior, or is navigator.javaEnabled () not the best way to perform a validation of java applets?

Thanks in advance.

+6
java firefox applet navigator
source share
4 answers

Make a method in your applet

 public boolean isRunning() { return true; } 

Now create an applet:

 <applet src=".../yourapplet.jar" id="someId"> 

And now wrap this code in some helper function

 try { var x = document.getElementById('someId').isRunning() return x; } catch(e) { return false; } 

Why does it work? If the applet starts, it will return true. If the applet does not start or Java is not supported, you will get an exception, so you will get false.

+10
source share

You can also try using an object tag.

With it, you can determine which version of java is installed and ask the user to download it if it does not exist.

This is an example object tag taken from the application I'm working on, the complexity of the JRE required us to work on 1.4.2_03 for compatibility with other applications.

  <object classid="clsid:CAFEEFAC-0014-0002-0003-ABCDEFFEDCBA" id="MyApplet" name="MyApplet" width="4" height="4" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2_03-windows-i586.cab#Version=1,4,2,03"> 

Classid indicates the version of Java you want to download, you can install it in a specific JRE, a specific family, that is 1.4.X or any other, latest version.

The codebase controls where the user is sent if they do not match the established class.

Please note that if the client is 1.5 or later, you cannot reference the older JRE due to security restrictions, you can override this through the registry setting in Windows, but I would not recommend it.

I believe that security is configured so that you can only reference the old JRE in the same family. that is, the user has 1.6.0.10, you can refer to 1.6.0.1, but you can’t go to anything in 1.5.X Although I think that I remember that after 1.6.0.11 a security dialog box appeared, where, as before , it simply rejected the request by default.

+1
source share

There is also a commercial product called BrowserHawk.

http://www.cyscape.com/products/bhawk/workshop/detectjava.aspx?bhcp=1

0
source share

I think this library has the most complete documentation and implementation that I can find and works well.

http://www.pinlady.net/PluginDetect/Java/

0
source share

All Articles