Maven "No compiler is provided" (JRE not JDK) - Fix in CI
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.
[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.
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21' # installs a full JDK with javac
- run: javac -version # confirm the compiler existsVerify javac is present in a container build
On a bare image, install the JDK package and confirm javac is on PATH.
apt-get update && apt-get install -y openjdk-21-jdk
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
javac -versionHow to prevent it
- 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.