# I'm getting "Fatal error compiling: invalid target release: 21" when trying to run "mvn test"

**URL:** <https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317>\
**Category:** Quality Assurance\
**Created:** [February 15, 2026, 4:22am UTC](https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317 "2026-02-15T04:22:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisxkeith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/chrisxkeith/32/21861_2.png) [@chrisxkeith](https://talk.openmrs.org/u/chrisxkeith)\
**Post date:** [February 15, 2026, 4:22am UTC](https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317/1 "2026-02-15T04:22:20Z")

</div>

```auto
[INFO] OpenMRS ............................................ SUCCESS [13.504 s]

[INFO] openmrs-tools ...................................... SUCCESS [4.887 s]

[INFO] openmrs-test ....................................... SUCCESS [0.322 s]

[INFO] openmrs-api ........................................ FAILURE [9.700 s]

[INFO] openmrs-web ........................................ SKIPPED

…

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.1:compile (default-compile) on project openmrs-api: Fatal error compiling: invalid target release: 21 ->

```

Running `mvn -e -X test` shows:

`[INFO] Compiling 774 source files with javac [debug target 21] to target/classes`

Is this referring to a Java version or something else? I installed Java 8 as described here: [https://openmrs.atlassian.net/wiki/spaces/docs/pages/25475060/Install+Java+SE](https://openmrs.atlassian.net/wiki/spaces/docs/pages/25475060/Install+Java+SE)

And I verified the versions as follows:

```auto
ck@2018-ck-nuc:~/Documents/github/openmrs-core$ java -version

openjdk version "1.8.0_482"

OpenJDK Runtime Environment (build 1.8.0_482-8u482-ga~us1-0ubuntu1~22.04-b08)

OpenJDK 64-Bit Server VM (build 25.482-b08, mixed mode)

ck@2018-ck-nuc:~/Documents/github/openmrs-core$ javac -version

javac 1.8.0_482

```

Or should I be running a different maven target (e.g., not `test`) to make sure that the automated tests pass?

Thanks in advance for any help.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [February 15, 2026, 8:56am UTC](https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317/2 "2026-02-15T08:56:35Z")

</div>

Openmrs core requires a minimum of java 21.

---

<div class="post-metadata">

**Author:** ![chrisxkeith](https://talk.openmrs.org/user_avatar/talk.openmrs.org/chrisxkeith/32/21861_2.png) [@chrisxkeith](https://talk.openmrs.org/u/chrisxkeith)\
**Post date:** [February 16, 2026, 8:14pm UTC](https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317/3 "2026-02-16T20:14:50Z")

</div>

Thank you! Once I have verified this works in my environment, should I update these pages to reflect that Java 21 is now required?

[https://openmrs.atlassian.net/wiki/spaces/docs/pages/25470205/Step+by+Step+Installation+for+Developers](https://openmrs.atlassian.net/wiki/spaces/docs/pages/25470205/Step+by+Step+Installation+for+Developers)[https://openmrs.atlassian.net/wiki/spaces/docs/pages/25475060/Install+Java+SE](https://openmrs.atlassian.net/wiki/spaces/docs/pages/25475060/Install+Java+SE)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [February 16, 2026, 8:24pm UTC](https://talk.openmrs.org/t/im-getting-fatal-error-compiling-invalid-target-release-21-when-trying-to-run-mvn-test/48317/4 "2026-02-16T20:24:39Z")

</div>

> [@chrisxkeith](#):
>
> Once I have verified this works in my environment, should I update these pages to reflect that Java 21 is now required?

Yes. But clearly indicate that it applies only for the master branch (3.0.0-SNAPSHOT)
