java -version
.java.home
directory of the JRE to check. The Java executable will be looked for under the <java.home>/bin
directory.JREVersionDetector detector = new JREVersionDetector(); // the timeOut will be the default timeOut of 200 ms detector.isAtLeastVersion(new File(<my JRE Location>), "1.7"); JREVersionDetector.setDefaultTimeOut(500L); // the timeOut will be the new default timeOut of 500 ms detector.isAtLeastVersion(new File(<my JRE Location>), "1.7"); JREVersionDetector detector2 = new JREVersionDetector(); detector2.setTimeOut(600L); // the timeOut will be 600 ms, the default timeOut has not changed detector.isAtLeastVersion(new File(<my JRE Location>), "1.7");
JREVersionDetector detector = new JREVersionDetector(); // return true if the version is at least 1.7 detector.isAtLeastVersion(new File(<my JRE Location>), "1.7"); // return true if the version is between 1.7 and 1.8 detector.isBetweenVersions(new File(<my JRE Location>), "1.7", "1.8", true); // return true if the version is between 1.7 and 1.8, and apply a timeOut detector.isBetweenVersions(new File(<my JRE Location>), "1.7", "1.8", true); // return true if the version is between 1.7 and 1.8, on a 32 bit architecture detector.isBetweenVersions(new File(<my JRE Location>), "1.7", "1.8", JREVersionDetector.32_BIT, true); // get the characteristics of the JRE, will allow to get the version and the architecture JREVersionDetector.JREConfig config = detector.getJREConfiguration(new File(<my JRE Location>));
Copyright 2006-2024 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences