Maven: The Complete Reference
   - 2.3. Installing Maven

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.

2.3.1. Installing Maven on Linux, BSD or Mac OSX

You can download a binary release of Maven from 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 PATH to a script that will run every time you login. To do this, add the following lines to .bash_login or .profile

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.


These installation instructions assume that you are running bash.

2.3.2. Installing Maven on Microsoft Windows

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:\Program Files\apache-maven-3.2.5, but it won’t make a difference if you install Maven in another directory as long as you configure the proper environment variables. Once you’ve unpacked Maven to the installation directory, you will need to set the PATH environment variable. You can use the following commands:

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.

Become a Member

Are you a current user of: