Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

maven

centos

When I ran the command

mvn clean package

I am getting 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 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 this?

like image 871
coure2011 Avatar asked Mar 22 '13 11:03

coure2011


3 Answers

Normally when execute the mvn -v you may 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 point to the JDK Version: 1.6.0-24 or other than your expect. Please simply set the JAVA_HOME to your JDK Version: 1.7.0_03 instead.

I hope this may help.

like image 116
Charlee Chitsuk Avatar answered Nov 06 '22 07:11

Charlee Chitsuk


Make sure that your environment (PATH) is set up to use the JDK version that you want to use for compiling. You can check this by running the following in the shell or command window where you want to run Maven:

java -version
javac -version

Make sure that both java and javac are pointing to the correct version. It's possible that you have a 1.7 JRE (which does not include the compiler) and a 1.6 JDK (which includes the compiler) and the wrong one is being used.

If necessary, adjust your JAVA_HOME and PATH environment variables.

Just noticed that you're on CentOS - it's possible that java and javac point to different versions. Use the alternatives command to check that, see here for an example: http://wiki.centos.org/HowTos/JavaRuntimeEnvironment - you will have to check both the java and the javac command.

like image 2
nwinkler Avatar answered Nov 06 '22 05:11

nwinkler


Check your JRE System Library in Eclipse. Does it show jdk1.6.0-24?

For me I had to right click the JRE System Library and go to Build Path -> Configure Build Path, in the Libraries tab I had to click JRE System Library and edit it. I set it to the Workspace Default JRE, which for me is jdk1.7.0_80 (not sure why it wasn't set to that already).

like image 2
Edac Avatar answered Nov 06 '22 05:11

Edac