Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (10.2k points)

I'm new to maven, and also to MacOS.

I have setup maven in my terminal, and when getting the version settings (using mvn -v) it seems it uses JDK 1.6, while I have JDK 1.7 installed. Is there anything wrong?

The commands I enter are these:

blues:helloworld Ninja$ java -version

java version "1.7.0_05"

Java(TM) SE Runtime Environment (build 1.7.0_05-b06)

Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)`

blues:helloworld Ninja$ mvn -v

Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28 10:15:32+0800)

Maven home: /usr/local/Cellar/maven/3.1.0/libexec

Java version: 1.6.0_51, vendor: Apple Inc.

Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Default locale: zh_CN, platform encoding: EUC_CN

OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"

1 Answer

0 votes
by (46k points)

add the following to your ~/.mavenrc:

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

Second Solution:

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile

Related questions

Browse Categories