From c5ed414ef1f798350fab0c5ba1c9e1351c9a23a7 Mon Sep 17 00:00:00 2001
From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Date: Mon, 23 Feb 2026 23:59:42 +0000
Subject: [PATCH] Upgrade Java 17 references to Java 21
- Remove Java 17 Maven profile from pom.xml (no longer needed since Java 21 is minimum)
- Update validateJavaVersion() in OpenmrsUtil.java to check for Java 21 minimum
- Update README.md to reflect Java 21 as minimum required version
Co-Authored-By: unknown <>
---
README.md | 2 +-
.../java/org/openmrs/util/OpenmrsUtil.java | 21 +++++++++----
pom.xml | 31 -------------------
3 files changed, 16 insertions(+), 38 deletions(-)
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