1

An applet developed outside our company just started failing for 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?

xecaps12
  • 5,316
  • 3
  • 27
  • 42

4 Answers4

1

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.

unholysampler
  • 17,141
  • 7
  • 47
  • 64
  • Is there a way to write the data back to the server in a log file or something? I'm more interested in the developers knowing it than the end users. – xecaps12 Mar 11 '11 at 17:18
  • @xecaps12: You can do whatever you want with it once you get the value, it is just a String. Writing it to a log file seems like it would be the best solution. – unholysampler Mar 11 '11 at 17:51
  • I just wasn't sure if it'd write it to the log on the server, I thought it'd would be written on the client's machine. – xecaps12 Mar 11 '11 at 20:23
  • @xecaps12: I've never done anything with web applets, so I can't help you there. However, since it is running on the client's computer, I would guess that it would not write to the server and you will need to write a small bit of code to signal the server. – unholysampler Mar 11 '11 at 20:29
1

You can use System.getProperty, specifically :

System.getProperty("java.version")

For a list of possible key value, see : getProperties()

krtek
  • 26,334
  • 5
  • 56
  • 84
0

http://pscode.org/prop/?prop=java.version%2Cjava.vm.version

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
0

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);     
        }
    });

});
Community
  • 1
  • 1
xecaps12
  • 5,316
  • 3
  • 27
  • 42