How to determine the Java runtime set on the client from an ASP.NET website?

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.

+3
source share
12 answers

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
}
+10

Java-.

http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html

, Deployment Toolkit (deployJava.js) JavaScript, HTML-, Java Web Start, .

+6

JavaScript navigator.javaEnabled(), , some Java.

System.getProperty("java.version") Java-. , , 1.6.0_03.

+5

, (), ASP.NET, , . , .

HTTP-, . Java , , . : http://www.developershome.com/wap/detection/ https://metacpan.org/pod/HTTP::Browscap

, , - javascript , ajax, , .

+2

java-, , .

+1

, 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>
0

. , javascript.

, . JRE messsage.

Javascript, , WebStart.

0
0

amd, ! , .

javascript: for(i = 0; i < navigator.plugins.length; i++) alert(navigator.plugins[i].name);

Java , , , - . javascript .

!

0

, . 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 }

Make sure that a specific version is installed: if (deployJava.versionCheck(version)) { //Your version specific code }

Run the latest Java installer: deployJava.installLatestJava();

Or a specific version if you want: deployJava.installJRE(version);

0
source

Copy and paste into your browser's address bar to check:

JavaScript: warning (navigator.javaEnabled ())

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

-1
source

Source: https://habr.com/ru/post/1702416/


All Articles