I'm trying to install maven through the terminal by following these instructions.
So far I got this
export M2_HOME=/user/apple/apache-maven-3.0.3 export M2=$M2_HOME/bin export PATH=$M2:$PATH export JAVA_HOME=/usr/java/jdk1.6.0_22
This is probably a stupid question where do you go to find this?
The output shows maven home location, the JDK it's using and also the Mac OS version details. Maven is successfully installed in your Mac OS. You are ready to create a maven based Java projects.
Once Maven is installed, you can check the version by running mvn -v from the command-line.
Overview. Simply put, Maven is a command-line tool for building and managing any Java-based project. The Maven Project provides a simple ZIP file containing a precompiled version of Maven for our convenience. There is no installer. It's up to us to set up our prerequisites and environment to run Maven.
Alternatively, I recommend installing Homebrew for these kinds of utilities.
Then you just install Maven using:
brew install maven
PS: If you got a 404 error, try doing a brew update
just before
Disclaimer: Here is a complete answer taking the last version of OS X (10.9 AKA Mavericks) into account. I am aware that everything I compiled in this answer is already present in the page, but having it clearly in one answer makes it a lot clearer.
First of all, with previous versions of OS X, Maven is installed by default. If Java is missing running you@host:~ $ java
in a terminal will prompt you for the Java installation.
With Mac OS X 10.9 (Mavericks), Maven is not installed by default anymore. Different options are then possible:
you@host:~$ brew install maven
will install latest Maven (3.5.2 on 02/01/2018)you@host:~$ brew install maven30
will install Maven 3.0 if neededyou@host:~$ sudo port install maven
will install latest Maven (?)you@host:~$ sudo port install maven3
will Install Maven 3.0you@host:~$ sudo port select --set maven maven3
selects that version of Mavenapache-maven-3.3.9-bin.tar.gz
to the directory you wish to install Maven 3.3.9. The subdirectory apache-maven-3.3.9
will be created from the archive.export MAVEN_OPTS="-Xms256m -Xmx512m"
. This environment variable can be used to supply extra options to Maven.export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
and that $JAVA_HOME/bin
is in your PATH
environment variable (although that might not be necessary with the latest Mac OS X versions and the Oracle JDK).apache-maven-3.3.9/bin
to your $PATH
mvn --version
to verify that it is correctly installed.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