Maven: The Complete Reference - 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. You can download a binary release of Maven from http://maven.apache.org/download.html. Download the current release of Maven in 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 /opt/apache-maven-3.2.5, you may want to create a symbolic link to make it easier to work with and to avoid the need to change any environment configuration when you upgrade to a newer version: $ cd /opt $ ln -s apache-maven-3.2.5 maven $ export PATH=/opt/maven/bin:${PATH} Once Maven is installed, you need to do a couple of things to make it work correctly. You need to add its bin directory in the distribution (in this example, /opt/maven/bin) to your command path. You’ll need to add export PATH=/opt/maven/bin:${PATH} Once you’ve added these lines to your own environment, you will be able to run Maven from the command line. NoteThese installation instructions assume that you are running bash. Installing Maven on Windows is very similar to installing Maven on Mac
OSX, 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=%PATH%;"c:\Program Files\apache-maven-3.2.5\bin" Setting these environment variables on the command-line will allow you to run Maven in your current session, but unless you add them to the System 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. |