Chris Chris - 1 year ago 79
Java Question

Java check latest version programatically

Goal: check java's version on a machine (I can get this from

java -version
). Compare it with latest available from java website

I would like to know if there is any way I can check for latest Java releases assuming that I have JRE/JDK installed on a machine.

If I can do this through Java itself, my solution would become platform independent. I could use
class to send a request to Java website and get the HTML, however the response would be dynamic as Oracle can change their website and styles and possibly will have maintenance issues in long run.

I have looked at, but I would not want it through an applet but through command line (which I can add to a script).

Through javacpl.exe, I can schedule periodic checks, but I would like to do it on demand.

Thanks in advance.

Answer Source

The answer is actually quite simple. issues a request to That file currently contains a single version number: '1.7.0_11'...which is the latest and greatest, indeed.

Java code example

try (BufferedReader br = new BufferedReader(new InputStreamReader(new URL(
    "").openStream()))) {
  String fullVersion = br.readLine();
  String version = fullVersion.split("_")[0];
  String revision = fullVersion.split("_")[1];
  System.out.println("Version " + version + " revision " + revision);
} catch (IOException e) {
  // handle properly

Update 2014-03-20

Eventhough Java 8 was recently released currently still returns 1.7.0_51.

Update 2016-07-13

Looks like we need to come back to this every few months... Currently you need to scan for a JavaScript variable latest8Version. So, you could run curl -s | grep latest8Version.