Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Maven 3.0.4 to use Java7?

I've just updated maven from 3.0.3 to 3.0.4 using the compiled binaries from the official site.Now when I run mvn -version , it says that it uses the old java 6 version , instead of the java 7 version that I have installed on my machine (macbook pro). If I run the 3.0.3 version maven binary from inside its folder it uses the java 7 version. How can I configure maven 3.0.4 so that it uses the Java 7 version? Thank you.

PS : Java 7 is the default java version at my system (mountain lion).

like image 374
skiabox Avatar asked Dec 19 '12 19:12

skiabox


People also ask

What is the current version of Maven used?

Apache Maven 3.8.6 is the latest release and recommended version for all users.

Does maven need JRE?

Maven needs a JDK, and not a JRE. Thanks, Ok yep it is installed.. both JDK and Maven... BUT JAVA_HOME returns Nothing...so still I have some configuration to do to set my JAVA_HOME on OSX ? and without that nothing (EClipse, IntelliJ, etc..)

What should Java_home be set to Windows?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.


2 Answers

Set the JAVA_HOME environment variable. and path as $JAVA_HOME/bin

From Apache maven:

Unix-based Operating Systems (Linux, Solaris and Mac OS X)

Extract the distribution archive, i.e. apache-maven-3.0.4-bin.tar.gz to the directory you wish to install Maven 3.0.4. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.0.4 will be created from the archive. In a command terminal,

add the M2_HOME environment variable, e.g. export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.4.

Add the M2 environment variable, e.g. export M2=$M2_HOME/bin.

Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.

Add M2 environment variable to your path, e.g. export PATH=$M2:$PATH.

Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.7.* and that $JAVA_HOME/bin is in your PATH environment variable.

Run mvn --version to verify that it is correctly installed.

like image 57
Festus Tamakloe Avatar answered Oct 30 '22 13:10

Festus Tamakloe


Set the JAVA_HOME environment variable.

like image 44
Sean Patrick Floyd Avatar answered Oct 30 '22 12:10

Sean Patrick Floyd