This code used to work fine with java 6 and 7, but running it with a jre 1.8 method getMajorJavaVersion returns 2. Is it a bug, or are we doing something wrong?
public static void validateJavaVersion() {
// check whether the current JVM version is at least Java 6
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_16) {
throw new APIException("OpenMRS requires Java 6, but is running under " + JdkVersion.getJavaVersion());
}
}
getJavaVersion gives the version as 1.8.0_20
Note that JdkVersion belongs to Spring, not to the JRE itself.
Another question: is there any API to compare two java versions? Preferably native but we can use Apache commons and Spring too.