Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven error :Perhaps you are running on a JRE rather than a JDK?

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 initially downloaded a whole bunch of dependencies, and in the end it showed,

COMPILATION ERROR :  [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error 

I am on ubuntu 13.04.

If there's anything you want me to tell you, let me know. Thanks.

EDIT

When I do echo $JAVA_HOME I get /usr/lib/jvm/java-7-openjdk-i386/

When I do mvn -version

I get,

Apache Maven 3.0.4 Maven home: /usr/share/maven Java version: 1.7.0_25, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-i386/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.8.0-26-generic", arch: "i386", family: "unix" 

Also, I found out this problem faced by someone else. But I am not sure how to go about the solution that is specified?

Further edits.

kraken@kraken-Inspiron-1545:/usr/lib/jvm/java-7-openjdk-i386$ ls -l total 12 drwxr-xr-x 2 root root 4096 Sep  9 10:44 bin lrwxrwxrwx 1 root root   41 Jul  4  2013 docs -> ../../../share/doc/openjdk-7-jre-    headless drwxr-xr-x 5 root root 4096 Oct 13  2013 jre drwxr-xr-x 4 root root 4096 Oct 13  2013 man 
like image 925
Kraken Avatar asked Oct 11 '14 10:10

Kraken


People also ask

Does Maven need JDK or JRE?

Maven needs a JDK, and not a JRE.

Can we use JRE instead of JDK?

Maven requires Eclipse using a JDK, i.e. Java Development Kit, instead of a Java Runtime Environment (JRE). The main difference is that a JDK also contains a Java Compiler and other tools to develop Java Code, while the JRE is only able to run compiled Java applications.


2 Answers

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.

like image 183
ced Avatar answered Oct 23 '22 01:10

ced


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.

like image 35
Kraken Avatar answered Oct 23 '22 01:10

Kraken