Skip to content

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

This error occurs when you are trying to run Maven to download some libraries for executing a Java program on a machine.This usually occurs when incorrect JDK path is set in the Environment variables. The environment variables might be referring to a JRE rather than the actual JDK itself

To set the environment variable correctly on Windows follow the below steps

Step 1: Go to Control Panel –> System

Step 2: Check whether System & Environment variables are setup correctly. If they are setup correctly then move on to the 3rd step. (JAVA_HOME should be referring to the root directory of the Java installations whereas JRE_HOME should be referring to the root directory of JRE). If they are not referring the correct paths then you may get an error like above, Fix it by entering the correct path in the Environment variables

Step 3: If the above steps doesn’t work out, check out the lib directory of JAVA installation folder and compare it lib directory from another JAVA installation. The error “you are running on a JRE rather than JDK” occurs when lib directory is missing important jars like tools.jar

Copying the tools.jar from another JAVA installation to the lib folder would solve the issue as Maven compile plugin needs tools.jar to compile the code. More about it can be found here