Maven "No compiler is provided" (JRE not JDK) - Fix in CI
By Kaveh Alemi·Latchkey
The maven-compiler-plugin could not find a Java compiler because Maven is running on a JRE, not a JDK. A JRE has the runtime but no javac, so compilation cannot proceed.
What this error means
The compile goal fails immediately with No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? - JAVA_HOME points at a JRE directory.
mvn output
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile)
on project app: No compiler is provided in this environment.
Perhaps you are running on a JRE rather than a JDK?
Common causes
JAVA_HOME points at a JRE
A JRE ships java but not javac or the compiler API. If JAVA_HOME (or PATH) resolves a JRE, the compiler plugin has nothing to compile with.
Only a JRE installed on the runner
A minimal image or one provisioned with a runtime-only package has no JDK, so the build can run Maven but cannot compile.
How to fix it
Install a full JDK and point JAVA_HOME at it
Provision a JDK (not a JRE) and set JAVA_HOME to its home directory.
.github/workflows/ci.yml
- uses:actions/setup-java@v4with:distribution:temurinjava-version:'21' # installs a full JDK with javac- run:javac -version # confirm the compiler exists
Verify javac is present in a container build
On a bare image, install the JDK package and confirm javac is on PATH.
Always provision a JDK (not a JRE) in CI and assert javac -version.
Point JAVA_HOME at a JDK home, never a JRE.
Use JDK base images for container builds.
Frequently asked questions
What causes ""No compiler is provided in this environment""?
A JRE ships java but not javac or the compiler API. If JAVA_HOME (or PATH) resolves a JRE, the compiler plugin has nothing to compile with.
How do I fix "No compiler is provided in this environment"?
Provision a JDK (not a JRE) and set JAVA_HOME to its home directory.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.