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?
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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With