How can I detect the Java runtime installed on a c

2019-01-23 21:40发布

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.

12条回答
Deceive 欺骗
2楼-- · 2019-01-23 22:05

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.

查看更多
欢心
3楼-- · 2019-01-23 22:13

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.

查看更多
再贱就再见
4楼-- · 2019-01-23 22:14

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:

if (navigator.javaEnabled()) {
    //Java is enabled
}
查看更多
霸刀☆藐视天下
5楼-- · 2019-01-23 22:15

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 as 1.6.0_03.

查看更多
Explosion°爆炸
7楼-- · 2019-01-23 22:15

Copy and paste into your browser address bar to check:

javascript:alert(navigator.javaEnabled())

Works in Mozilla (FF3) and IE7. (x64)

查看更多
登录 后发表回答