I have an ASP .NET website that hosts a Java applet. The Java applet requires version 1.6 Update 11 of the Java runtime.
How can I detect that a client has the appropriate runtime installed so that I can display an informative message if they do not?
Thanks,
Carl.
EDIT: The solution must be platform independant.
If the solution must be platform independent. I'll exclude all solution provided by javascript.
You can write a very simple Applet which support by the oldish Classic VM. Let the applet detect the JRE version, and display messsage.
If you accept Javascript, you may also interest to this article which is about auto-installer for WebStart applications.
Although most of the answers so far are all around detection on the user agent (browser) itself, it sounds like from your mention of ASP.NET that you'd like to make this detection happen on the server-side. If so, you have a couple of options.
First you can sniff the HTTP request headers coming from the user agent. A computer and browser with Java installed will usually include a header providing a hint of this to the server that you can pick up on. Here are some useful links on this approach: http://www.developershome.com/wap/detection/ https://metacpan.org/pod/HTTP::Browscap
The other option you have is to send down javascript to the user agent to perform the detection using one of the techniques in the other answers in this question and then use ajax callbacks to tell the server what you discovered.
This page describes how to and lists some plugins that will allow you to detect Java with JavaScript: http://www.pinlady.net/PluginDetect/JavaDetect.htm
Other than that, try out this snippet as well:
My approach would be to use the JavaScript
navigator.javaEnabled()
to check if there is some Java version available.Then you can use
System.getProperty("java.version")
from within a Java applet itself. That should be enough to get you the version information, such as1.6.0_03
.check this
http://simple-java-detection-script.blogspot.com/2010/03/simple-browser-java-installed-or.html
Copy and paste into your browser address bar to check:
javascript:alert(navigator.javaEnabled())
Works in Mozilla (FF3) and IE7. (x64)