I have an ASP.NET site that hosts a Java applet. Java applet requires version 1.6 Update 11 of the Java runtime.
How can I detect that the client has an installed runtime so that I can display an informative message if this is not so?
Thanks,
Charles.
EDIT: The solution must be platform independent.
This page describes how some plugins that allow you to discover Java with JavaScript are listed: http://www.pinlady.net/PluginDetect/JavaDetect.htm
, :
if (navigator.javaEnabled()) { //Java is enabled }
Java-.
http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html
, Deployment Toolkit (deployJava.js) JavaScript, HTML-, Java Web Start, .
JavaScript navigator.javaEnabled(), , some Java.
navigator.javaEnabled()
System.getProperty("java.version") Java-. , , 1.6.0_03.
System.getProperty("java.version")
1.6.0_03
, (), ASP.NET, , . , .
HTTP-, . Java , , . : http://www.developershome.com/wap/detection/ https://metacpan.org/pod/HTTP::Browscap
, , - javascript , ajax, , .
java-, , .
, script. Windows.
<script language='javascript' type='text/javascript'> 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\\"); } 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(...)' alert('error reading registry'); } } } 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.6) Java Plugin if ( javaVersion != null && javaVersion.indexOf("1.6")) { pluginDetected = true; alert('it is installed!') } if (pluginDetected) { // show applet page } else if (confirm("Java Plugin 1.6 not found")) { // show install page alert('not found') } else { // show error page alet('error') } </script>
. , javascript.
, . JRE messsage.
Javascript, , WebStart.
deployJava.js getJREs() Java.
http://cowwoc.blogspot.com/2008/12/tracking-java-versions-using-google.html, Java, - Google Analytics.
: 2 , 1.
amd, ! , .
javascript: for(i = 0; i < navigator.plugins.length; i++) alert(navigator.plugins[i].name);
Java , , , - . javascript .
!
http://simple-java-detection-script.blogspot.com/2010/03/simple-browser-java-installed-or.html
, . JS, , Java. , , .
, .
http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit
After downloading the deployJava.js file, you can put something to make sure java is installed: if (deployJava.getJREs().length > 0) { //Your code to start java }
if (deployJava.getJREs().length > 0) { //Your code to start java }
Make sure that a specific version is installed: if (deployJava.versionCheck(version)) { //Your version specific code }
if (deployJava.versionCheck(version)) { //Your version specific code }
Run the latest Java installer: deployJava.installLatestJava();
deployJava.installLatestJava();
Or a specific version if you want: deployJava.installJRE(version);
deployJava.installJRE(version);
Copy and paste into your browser's address bar to check:
JavaScript: warning (navigator.javaEnabled ())
Works in Mozilla (FF3) and IE7. (64)
Source: https://habr.com/ru/post/1702416/More articles:IPhone app in background - objective-cCan you recommend a Python SOAP client that can accept WS-Attachments? - pythonКак отправить файл через Soap в python? - pythonСлучайные числа из базы данных - sqlDB connections in ASP.NET, MySQL and SQL Server - mysqluploaded files - database and file system, using Grails and MySQL - mysqlCan I use applications using Java 1.4.2_12 and Java 1.5 on the same Windows server? - javaКак я могу упорядочить объекты в соответствии с каким-либо атрибутом дочернего элемента в sqlalchemy? - python[DBNETLIB] [ConnectionOpen (SECDoClientHandshake ()).] SSL Security Error - iisImport dll Eclipse C ++ - c ++All Articles