Skip to content
Latchkey

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.

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@v4
  with:
    distribution: temurin
    java-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.

Terminal
apt-get update && apt-get install -y openjdk-21-jdk
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
javac -version

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →