0

I am getting the following error while using the following command

mvn clean install package

Error

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

I have tried the solutions already present online but none of them worked, I have my JDK path selected in the installed JRE's on my eclipse. I am using Ubuntu 16.04. Can someone help?

I have already tried the solution given in No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? but that didn't help. I already have my JDK path selected correctly

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
Bhargav
  • 697
  • 3
  • 11
  • 29

3 Answers3

1

Check JAVA_HOME path is set as the environment variable pointing to JDK. Refer maven installation steps for more information.

https://maven.apache.org/install.html

Murthy
  • 19
  • 3
1

Give the jdk path in /etc/environment

Eg : JAVA_HOME="/usr/lib/jvm/java-8-oracle"

then

source /etc/environment

also add in bashrc

vi ~/.bashrc
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"
source ~/.bashrc
Anto Livish A
  • 322
  • 4
  • 15
0

I had this same exact error.

There are a lot of possible solutions posted for this problem, even more duplicates. However, after checking many of them I did not find the solution. After some tries and investigations among my environment settings I have found out that the issue was caused by having multiple java paths pointing to different versions that were set up by different IDE's. Also, it seems that Maven was trying to use the first version it found in the PATH settings which actually appeared to be a JRE version.

The solution for me was to put the path pointing to Java JDK as the first path in the PATH environment settings.

Also, make sure that the new environment settings are in effect before you try to use Maven again.

A very simple way to see if mvn actually tries to use the JDK is to execute the following command:

mvn -version

It will print out the Java paths along with other info.

Joseph
  • 51
  • 3