diff --git a/README.md b/README.md index 898f9f551fa3..4b7bd1fb8c96 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The mission of OpenMRS is to improve health care delivery in resource-constraine OpenMRS is a Java application which is why you need to install a Java JDK. -If you want to build the master branch you will need a Java JDK of minimum version 8. +If you want to build the master branch you will need a Java JDK of minimum version 21. #### Maven diff --git a/api/src/main/java/org/openmrs/util/OpenmrsUtil.java b/api/src/main/java/org/openmrs/util/OpenmrsUtil.java index a942de53285f..b0b867a84cda 100644 --- a/api/src/main/java/org/openmrs/util/OpenmrsUtil.java +++ b/api/src/main/java/org/openmrs/util/OpenmrsUtil.java @@ -1070,16 +1070,25 @@ public static String getOpenmrsLogLocation() { } /** - * Checks whether the current JVM version is at least Java 8. + * Checks whether the current JVM version is at least Java 21. * - * @throws APIException if the current JVM version is earlier than Java 8 + * @throws APIException if the current JVM version is earlier than Java 21 */ public static void validateJavaVersion() { - // check whether the current JVM version is at least Java 8 - if (System.getProperty("java.version").matches("1\\.[0-7]\\.(.*)")) { + // check whether the current JVM version is at least Java 21 + String version = System.getProperty("java.version"); + int majorVersion; + try { + String majorStr = version.contains(".") ? version.substring(0, version.indexOf('.')) : version; + majorVersion = Integer.parseInt(majorStr); + } catch (NumberFormatException e) { + // If we can't parse the version, skip validation + return; + } + if (majorVersion < 21) { throw new APIException( - "OpenMRS " + OpenmrsConstants.OPENMRS_VERSION_SHORT + " requires Java 8 and above, but is running under " + - System.getProperty("java.version")); + "OpenMRS " + OpenmrsConstants.OPENMRS_VERSION_SHORT + " requires Java 21 and above, but is running under " + + version); } } diff --git a/pom.xml b/pom.xml index 804c3d3d97f3..cd6b4e9ea31a 100644 --- a/pom.xml +++ b/pom.xml @@ -1168,37 +1168,6 @@ - - - java17 - - 17 - - - - - org.mockito - mockito-core - 5.19.0 - - - net.bytebuddy - byte-buddy - 1.17.7 - - - net.bytebuddy - byte-buddy-agent - 1.17.7 - - - - - java21