1

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
AnNaMaLaI
  • 4,064
  • 11
  • 53
  • 93

2 Answers2

3

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
Gray
  • 115,027
  • 24
  • 293
  • 354
  • Thanks [~gray] and [~satya] I installed the JDK and Eventually it works. – AnNaMaLaI Mar 23 '17 at 04:25
  • 1
    Tested on CentOS 6.5. sudo yum install java-1.7.0-openjdk.x86_64 installs only JRE(javac will be absent). sudo yum install java-1.7.0-openjdk-devel installs JDK. from http://stackoverflow.com/a/12792019/744478 – AnNaMaLaI Mar 23 '17 at 04:25
0

This problem occurs because on many reasons:

  1. If you haven't installed the JDK package. For example, you have installed java-11-openjdk.x86_64 but JDK comes with a development package. For instance, java-11-openjdk-devel.x86_64 is a java jdk package. It always comes with the extension devel.
  2. Inappropriate java versions, like a project that requires java 17 but we may have installed java 11.
NotePub
  • 1
  • 1