Skip to content

/errors/maven/no-compiler-is-provided-in-this-environment

Maven: No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

The commands on this page have not been executed by our verification runner yet.updated
tool
Maven
exit code
1
versions
Maven 3.x, maven-compiler-plugin 3.x
os
linux, macos, windows

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? means the maven-compiler-plugin asked the running Java for its built-in compiler and got none. A JRE (runtime only) can run Java programs but has no javac. Maven compiles with the Java found through JAVA_HOME (or java on the PATH). Install a JDK, point JAVA_HOME to it, and check the result with mvn -v.

Where the message comes from

The text is produced by the javac compiler adapter of plexus-compiler, which the maven-compiler-plugin uses: when ToolProvider.getSystemJavaCompiler() returns nothing, the plugin reports this message as a compilation error and the build stops with BUILD FAILURE in the compile (or testCompile) goal.

Check which Java Maven uses

bash
mvn -v                         # look at the "Java version" and "runtime" lines
echo "$JAVA_HOME"
ls "$JAVA_HOME/bin/javac"      # must exist for a JDK

Fix

Linux (bash), after installing a JDK:

bash
export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk   # replace with your JDK folder
export PATH="$JAVA_HOME/bin:$PATH"
mvn -v

Windows (PowerShell), for the current user:

powershell
[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\Program Files\Eclipse Adoptium\jdk-21', 'User')

Open a new terminal afterwards so the variable is picked up.

Sources