I\'ve never worked with Maven before and I am following the instructions here. When I run the command
mvn integration-test -Pamp-to-war
It
Problem statement = No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Solution
Please set the Environment variable like below to solve the issue
Variable name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_202
Variable name : M2_HOME
Variable Value : C:\Program Files\apache-maven-3.6.0
Moreover, Add Java and maven path in "System Variables" like below:
I've been facing the same issue with java 8 (ubuntu 16.04), trying to compile using mvn
command line.
I verified my $JAVA_HOME
, java -version
and mvn -version
. Everything seems to be okay pointing to /usr/lib/jvm/java-8-openjdk-amd64
.
It appears that java-8-openjdk-amd64 is not completly installed by default and only contains the JRE (despite its name "jdk").
Re-installing the JDK did the trick.
sudo apt-get install openjdk-8-jdk
Then some new files and new folders are added to /usr/lib/jvm/java-8-openjdk-amd64
and mvn is able to compile again.
For me, it worked like following. Please look at JAVA_HOME environment variable, whether it is pointing to JRE or JDK.? If it pointed to JRE, you will face "Perhaps you are running on a JRE rather than a JDK" issue. if so change the path to JDK.
Modifying like this, it worked for me.
JAVA_HOME C:\Program Files\Java\jdk1.8.0_31
I faced the issue even though JAVA_HOME was pointing to JDK. It took time to figure out why it was throwing the exception.
The issue was I set JAVA_HOME as admin user on my window machine. You need to add JAVA_HOME environment variable pointing to right JDK to your user profile environment variable settings.
Just adding more details on where to setup. Main reason would be the JAVA_HOME setup in the environment variable should be pointing to correct JDK location.
- Check System -> Advance System Settings
- Click on Environment variable
- Add variable JAVA_HOME -> "C:\Program Files\Java\jdk1.8.0_141;"
- Edit "path" -> append %JAVA_HOME%; to the existing text.
In Installed JREs path see if there is an entry pointing to your JDK path or not.
If not, click on Edit button and put the path you configured your JAVA_HOME
environment:
Eclipse Path: Window → Preferences → Java → Installed JREs