Maven is written in Java. For this you need to install the Java JDK. Once Java is installed, you must ensure that the commands from the Java JDK are in your PATH environment variable.

Verify that Java was successfully installed by running the following command:

$ java -version

Installing Maven on Windows

  • Make sure JDK is installed, and JAVA_HOME environment variable is configured.
  • Visit Maven official website, download the Maven zip file, for example :
  • Unzip it to a folder. I are using c:\opt\apache-maven-3.6.3
  • Add MAVEN_HOME system variable

In System Properties dialog, select Advanced tab and clicks on the Environment Variables... button.

In “Environment variables” dialog, System variables, Clicks on the New... button and add a MAVEN_HOME variable and point it to c:\opt\apache-maven-3.6.3

  • In system variables, find PATH, clicks on the Edit... button. In “Edit environment variable” dialog, clicks on the New button and add this %MAVEN_HOME%\bin

Installing Maven on macOS

With Mac OS X, Maven is not installed by default anymore. Different options are then possible:

# will install latest Maven
$ brew install maven
# will install Maven 3.0 if needed
$ brew install maven30 
# will install latest Maven
$ sudo port install maven 
# will Install Maven 3.0
$ sudo port install maven3 
  • Installing by hand: Download Maven from its homepage

Follow the installation instructions:

  1. Move to home folder and create a new folder for maven artifacts:

cd ~ && mkdirDevelopment

  1. Extract the distribution archive, i.e.apache-maven-3.6.3-bin.tar.gz to the directory you wish to install Maven 3.6.3. The subdirectory apache-maven-3.6.3 will be created from the archive.
  2. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.
  3. Make sure that JAVA_HOME is set to the location of your JDK, e.g. 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).
  4. Add extracted apache-maven-3.6.3/bin to your $PATH
  5. uncompress it ( and added maven path into environment variable PATH. Normally is edit and add:

export PATH=/Development/apache-maven-3.6.3/bin:$PATH

into your startup script( ~/.bashrc or ~/.zshrc etc.)

7. Create a symbolic link of the uncompressed file:

  • ln -s ~/Development/apache-maven-3.6.3 /usr/local/apache-maven

8. Verify that it is correctly installed by typing the mvn -version command:

$ mvn -version

The output should look something like this:

Installing Maven on Linux

Installing Apache Maven on Debian or Ubuntu with Apt

# First, update the package index:
$ sudo apt update
# Install Maven by running the following command:
$ sudo apt install maven
# Verify the installation by typing:
$ mvn -version

Installing Maven on CentOS 7 using yum is a simple, straightforward process.

$ sudo yum install maven
  • Installing by hand:
$ cd ~ && mkdir installed-packages
# Go to and wget the latest artifact:
# If you don't have wget installed: sudo yum install -y wget
$ cd ~/installed-packages
# Uncompress the downloaded file:
$ tar -xvf apache-maven-3.6.3-bin.tar.gz
# Create a symbolic link of the uncompressed file:
$ ln -s ~/installed-packages/apache-maven-3.5.0 /usr/local/apache-maven
# Edit ~/.bash_profile (This is where environment variables are commonly stored):
$ vi ~/.bash_profile
# Add the variable: MAVEN_HOME=/usr/local/apache-maven (do this before PATH variable is defined)
# (For those who don't know vi tool: Press i key to enable insert mode)
# Go to the end of the line where PATH variable is defined and append the following: :$MAVEN_HOME:$MAVEN_HOME/bin
# Save changes
# (For those who don't know vi tool: Press esc key to exit insert mode and :wq! to save and quit file)
# Reload environment variables:
$ source ~/.bash_profile
# Confirm that maven command now works properly:
$ mvn --help

Verify the installation

 $ mvn -version