Perform the following steps to install Maven on your system:
Download Maven from http://maven.apache.org/download.cgi. At the time of writing this book, version 3.2.3 is the latest version, and that is what was used in the book.
Once downloaded, extract the archive to the location of your chosen directory. We refer to this as
M2_HOME
.Include the extracted location in your path variable so that
mvn
is available on the terminal:For example, if you extracted the archive to
c:\devtools\apache-maven-3.2.3
on Windows, or/Users/bayo/devtools/apache-maven-3.2.3
on Unix/Mac OS, you will proceed with the following steps:
On Windows:
set M2_HOME=c:\devtools\apache-maven-3.2.3 set PATH=%PATH%;%M2_HOME%\bin;
On Unix/Mac OS:
export M2_HOME=/Users/bayo/devtools/apache-maven-3.2.3 export PATH=$PATH:$M2_HOME/bin
Alternatively, you could set these in your shell profiles, for example, ~/.zshrc
(for Zsh) or ~/.bash_profile
(for Bash) for convenience.