/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?
- 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
mvn -v # look at the "Java version" and "runtime" lines
echo "$JAVA_HOME"
ls "$JAVA_HOME/bin/javac" # must exist for a JDKFix
Linux (bash), after installing a JDK:
export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk # replace with your JDK folder
export PATH="$JAVA_HOME/bin:$PATH"
mvn -vWindows (PowerShell), for the current user:
[Environment]::SetEnvironmentVariable('JAVA_HOME', 'C:\Program Files\Eclipse Adoptium\jdk-21', 'User')Open a new terminal afterwards so the variable is picked up.
Sources
- maven.apache.orgmaven.apache.org/plugins/maven-compiler-plugin/
- maven.apache.orgmaven.apache.org/install.html
- maven.apache.orgmaven.apache.org/configure.html
- github.comgithub.com/codehaus-plexus/plexus-compiler/blob/master/plexus-compilers/plexus-compiler-javac/src/main/java/org/codehaus/plexus/compiler/javac/JavaxToolsCompiler.java