Ask is moving to Stack Overflow and! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode


JDK Error during Maven Build

asked 2014-06-28 11:54:13 -0700

Mierdin gravatar image

updated 2014-06-28 11:55:44 -0700

When performing a "mvn clean install" on essentially any maven-based Open Daylight project, I get the following error:

org.apache.maven.enforcer.rule.api.EnforcerRuleException: Detected JDK Version: 1.6.0-65 is not in the allowed range 1.7.0.

Of course, the Enforcer plugin is responsible for making sure this version is enforced, so naturally, we also get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-java) on project ovsdb_commons: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

As a result, the build fails. This is strange, considering that my JDK version is indeed 1.7:

~/C/ovsdb ??? java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
~/C/ovsdb ??? ls  -l /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x  3 root  wheel  102 May  9 13:08 jdk1.7.0_55.jdk
~/C/ovsdb ???

Why would the Java version mismatch in this way?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-28 11:54:56 -0700

Mierdin gravatar image

This is probably because Maven is using JDK 1.6 by default. This is a popular problem on Mac OSX (but could theoretically also occur on other platforms):

~/C/ovsdb ??? mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T12:37:52-05:00)
Maven home: /usr/local/Cellar/maven/3.2.1/libexec
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9.3", arch: "x86_64", family: "mac"

To fix this, just add this line to your ~/.mavenrc file (create the file if it doesn't exist):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/{jdk-version}/Contents/Home

This will allow Maven to use your installed JDK, without affecting other applications that use Java.

Happy hacking!

edit flag offensive delete publish link more


Thanks, This worked for me.

ransari ( 2015-01-12 10:39:12 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-06-28 11:54:13 -0700

Seen: 2,353 times

Last updated: Jun 28 '14