Detected JDK version: 1.6.0-24 is not in the allowed range 1.7

When I ran the command

mvn clean package 

I get an error:

 Detected JDK Version: 1.6.0-24 is not in the allowed range 1.7. 

How to fix the above error? I tried to check the jdk version isntalled and got this

 java version "1.7.0_03" Java(TM) SE Runtime Environment (build 1.7.0_03-b04) Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode) 

How to fix it?

+4
source share
3 answers

Usually when you run mvn -v you can see something like

 Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 20:51:28+0700) Maven home: C:\Java.Application\Apache\apache-maven-3.0.5\bin\.. Java version: 1.7.0_15, vendor: Oracle Corporation Java home: C:\Java.Application\Sun\Java\jdk1.7.0_15\jre Default locale: en_US, platform encoding: MS874 OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows" 

If the result points to JDK Version: 1.6.0-24 or other than expected. Just set JAVA_HOME instead of JDK Version: 1.7.0_03 .

Hope this helps.

+8
source

Make sure your environment (PATH) is configured to use the version of the JDK that you want to use for compilation. You can verify this by running the following in a shell or shell window where you want to run Maven:

 java -version javac -version 

Make sure both java and javac point to the correct version. It is possible that you have 1.7 JRE (which does not include the compiler) and 1.6 JDK (including the compiler), and the wrong one is used.

Adjust the JAVA_HOME and PATH environment variables as necessary.

Just noticed that you are on CentOS - it is possible that java and javac point to different versions. Use the alternatives command to verify this, see here an example: http://wiki.centos.org/HowTos/JavaRuntimeEnvironment - you will need to check both java and the javac command.

+1
source

Check out the JRE library in Eclipse. Does it show jdk1.6.0-24?

For me, I had to right-click on the JRE System Library and go to "Build Path" β†’ "Configure Build Path", on the "Libraries" tab I had to click on the JRE System Library and edit it. I installed it in the default workspace JFS, for me it is jdk1.7.0_80 (I don’t know why it has not been installed yet).

+1
source

All Articles