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

13,200

Solution 1

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.

Solution 2

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.

Solution 3

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).

Share:
13,200
coure2011
Author by

coure2011

Updated on June 12, 2022

Comments

  • coure2011
    coure2011 almost 2 years

    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?

  • coure2011
    coure2011 about 11 years
    I need to run command using sudo then it works "sudo -i mvn clean package"
  • Kevin Bowersox
    Kevin Bowersox over 8 years
    If you set the java home in the command line you need to open and close the cli