Maven error :Perhaps you are running on a JRE rather than a JDK?
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.
This is because of running jre rather than jdk, to install jdk follow below steps
Installing java 8 in amazon linux/redhat
--> yum search java | grep openjdk
--> yum install java-1.8.0-openjdk-headless.x86_64
--> yum install java-1.8.0-openjdk-devel.x86_64
--> update-alternatives --config java
#pick java 1.8 and press 1
--> update-alternatives --config javac
#pick java 1.8 and press 2
Thank You
Apparently, it requires tools.jar file inside the lib folder of my $JAVA_HOME. I did not have the lib folder, so I reinstalled my jdk using command
apt-get install openjdk-7-jdk openjdk-7-doc openjdk-7-jre-lib
Also, this link may help some people.