Search code examples
javamavenmaven-3

Maven Trying to compile in Linux environment using command line : No compiler is provided in this environment


I am trying to generate a build using maven, So started with mvn clean package command in linux server and Getting error as follows:

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

I searched and found some solutions so changed my JAVA_HOME path etc. And following is my settings

  • My JAVA_HOME => /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64/jre
  • MVN VERSION SHOWS: Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
  • Maven home: /home/ec2-user/.sdkman/candidates/maven/current
  • Java version: 1.7.0_131, vendor: Oracle Corporation
  • Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64/jre
  • OS name: "linux", version: "4.4.51-40.58.amzn1.x86_64", arch: "amd64", family: "unix"**

MY POM.XML File as follows: enter image description here


Solution

  • My JAVA_HOME => /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64/jre

    By this I assume you mean setting an environmental variable. Mine is set to the directory right above yours. I'd try that.

    export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64
    

    Mine is set like the following which may not work for you but is here as an example:

    export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    

    When I ls that directory I get the following. You should get something similar.

    $ ls /usr/lib/jvm/java-7-openjdk-amd64
    ASSEMBLY_EXCEPTION  docs     jre  man      THIRD_PARTY_README
    bin                 include  lib  src.zip