Can you capture end user's Java version when they run an applet?
An applet developed outside our company just started failing for开发者_JAVA百科 some users this week. Apparently it was because of the latest version of java (1.6u24) that auto updated. Is there a way to capture what version of java the user opened the applet with?
You can use System.getProperty("java.version")
to get that information. This is an example applet that uses it and the About page has the source.
You can use System.getProperty, specifically :
System.getProperty("java.version")
For a list of possible key value, see : getProperties()
http://pscode.org/prop/?prop=java.version%2Cjava.vm.version
Using the answers from another question, I ended up writing the code below. When the page loads, I get the user's java version then use an ajax call to save it where ever I need to. The part I used was the reference to the deployJava.js from Sun.
$(document).ready(function() {
var jVersion = "";
for (var i = 0; i < deployJava.getJREs().length; ++i) {
jVersion += deployJava.getJREs()[i];
}
var url = 'saveJavaVersionAction.jsp';
var params = 'version=' + jVersion;
$.ajax({
url: url,
data: params,
success: function(html) {
$("#results").append(html);
}
});
});
精彩评论