|Maven by Example
- 2.3. Installing Maven
There are wide differences between operating systems such as Mac OS X and Microsoft Windows, and there are subtle differences between different versions of Windows. Luckily, the process of installing Maven on all of these operating systems is relatively painless and straightforward. The following sections outline the recommended best-practice for installing Maven on a variety of operating systems.
Download the current release of Maven from http://maven.apache.org/download.html.
Choose a format that is convenient for you to work
with. Pick an appropriate place for it to live, and expand the archive
there. If you expanded the archive into the directory
/usr/local % cd /usr/local /usr/local % ln -s apache-maven-3.0.5 maven /usr/local % export PATH=/usr/local/maven/bin:$PATH
Once Maven is installed, you need to add its
You’ll need to add the
Once you’ve added these lines to your own environment, you will be able to run Maven from the command line.
These installation instructions assume that you are running bash.
Installing Maven on Windows is very similar to installing Maven on Mac
OS X, the main differences being the installation location and the
setting of an environment variable. This book assumes a Maven
installation directory of
C:\Users\tobrien > set PATH="c:\Program Files\apache-maven-3.0.5\bin";%PATH%
Setting this environment variable on the command line will allow you to run Maven in your current session. Unless you add them to the System or User environment variables through the Control Panel, you’ll have to execute these two lines every time you log into your system. You should modify both of these variables through the Control Panel in Microsoft Windows.