Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53657

How to write JavaScript function to check JRE version

I am new to JavaScript. How to write JavaScript function which will return installed Java version in the computer.

Thanks
Sunil Kumar Sahoo

Upvotes: 7

Views: 11738

Answers (4)

dfa
dfa

Reputation: 116342

use the JNLP, the Sun Unified Deployment Mechanism, the getJREs() function is your answer:

<script src="http://www.java.com/js/deployJava.js"></script>
<script>
     var versions = deployJava.getJREs();
     alert(versions);
</script>

NB

it works in a consistent fashion across various browsers

Upvotes: 13

YOU
YOU

Reputation: 123841

Normally, You cannot directly check Java Version from Javascript, You will need 2 steps.

  • Check Java is installed or not with javascript first

    navigator.javaEnabled()

  • And then load your java applet, and check it there for version.

PS: DeployJava mentioned by others, also doing similar method

Here is some of its codes, writing object tags to page, and checking it.

document.write('<'+'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
document.write('<'+'object classid="clsid:CAFEEFAC-DEC7-0000-0000-ABCDEFFEDCBA"

Upvotes: 0

Daniel May
Daniel May

Reputation: 8226

You can use the deployJava.getJREs() method in the Deployment System (returns a list of currently installed JREs).

Upvotes: 2

bora.oren
bora.oren

Reputation: 3499

var JavaVersion = PluginDetect.getVersion('Java', 'getJavaInfo.jar');
var Java0Status = PluginDetect.isMinVersion('Java', '0', 'getJavaInfo.jar');
alert('Java version is ' + JavaVersion + '\n' + 'Java status is ' + Java0Status);

This is the plugin detect generator page, also you can check here for detail about that.

Upvotes: 4

Related Questions