I am trying to use deployJava to get client java version. But deployJava.getJREs() is returning empty value. I am using windows 7-64bit.
Is there any way to detect client java version?
Mohi
1,7981 gold badge28 silver badges42 bronze badges
-
FYIBhargav Modi– Bhargav Modi2015年04月23日 07:51:38 +00:00Commented Apr 23, 2015 at 7:51
-
What does this have to do with JavaScript?Siguza– Siguza2015年04月23日 07:54:52 +00:00Commented Apr 23, 2015 at 7:54
1 Answer 1
firstly you need to verify whether java is enabled on client machine using below code snippet
navigator.javaEnabled()
if it returns true that means java is enabled and now futher you below code snippet
Version of Java:
/**
* @return NULL if not version found. Else return some things like: '1.6.0_31'
*/
var JavaVersion: function()
{
var resutl = null;
// Walk through the full list of mime types.
for( var i=0,size=navigator.mimeTypes.length; i<size; i++ )
{
// The jpi-version is the plug-in version. This is the best
// version to use.
if( (resutl = navigator.mimeTypes[i].type.match(/^application\/x-java-applet;jpi-version=(.*)$/)) !== null )
return resutl[1];
}
return null;
}
or you can use javascript
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var versions = deployJava.getJREs();
</script>
answered Apr 23, 2015 at 7:57
Bhargav Modi
2,6553 gold badges33 silver badges50 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
WilliamK
The first script throws an error, but the second one returns a version number
lang-js