Apache maven installation is really simple. You just need to make sure that JDK is installed and JAVA_HOME is configured correctly. All you do is unzip the maven zip/tar file and add apache-maven-3.6.1/bin to PATH.


  • Make sure JDK is installed in your system by running java -version in the terminal or command prompt.
  • If JDK is not installed yet, download it from the oracle site and follow the instructions to install it.

1. Install maven on Windows

  1. Set an environment variable JAVA_HOMEto JDK installation path. I am using JDK 8, so JAVA_HOME is pointing to C:\Program Files\Java\jdk1.8.0_172.
  2. Download the latest maven binary zip from Apache Maven site. When I created this tutorial, the latest version was apache-maven-3.6.1-bin.zip
  3. Unzip the archive and move it to Program Files. In my case, C:\Program Files\apache-maven\maven-3.6.1
  4. Set the environment variables M2_HOME and M2 using system properties for maven. M2_HOME=C:\Program Files\apache-maven\maven-3.6.1 M2=%M2_HOME%\bin
  5. Verify maven installation now by typing mvn --version in the command prompt.

2. Install maven on Mac

  1. Make sure JDK is installed. I advise making use of brew cask for mac. Install brew in Mac and then install cask if not installed. Now, you can install JDK by running brew cask install java8 for jdk8 or for the latest version of JDK.
  2. Once JDK is installed, you can use brew search maven to find the latest version of available maven and then install the right version using brew install, for example brew install [email protected] will install maven-3.5.
  3. Now type mvn -v to verify that the installation was successful.

Alternatively, you can also download the binary zip or tar from official maven site, extract them, move it to a correct directory and then add /bin to the PATH.

3. Install maven on Linux

  1. I am assuming JDK is installed correctly in your LINUX.
  2. You can use wget or visit the link from a browser to download the binary tar file. Download the binary apache-maven-3.6.1-bin.tar.gz file from Maven site to /tmp/ folder. There may be a different version there, but the steps are the same.
  3. Navigate to the folder where you want to install. I prefer installing in /opt/, so run cd /opt/ in the terminal.
  4. Now extract the archive using sudo tar -xvzf /tmp/apache-maven-3.6.1-bin.tar.gz. This will extract and move the content to /opt/apache-maven-3.6.1/bin
  5. Set M2_HOME and PATH to maven bin by modifying the /etc/environment file. Use the below code as an example, you can use nano or vi text editors. Make sure you do not change any existing values, you only append :/opt/apache-maven-3.6.1/bin for PATH and M2_HOME="/opt/apache-maven-3.6.1"
  1. After making changes in the environment file, update the maven command
sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/opt/apache-maven-3.6.1/bin/mvn" 0
sudo update-alternatives --set mvn /opt/apache-maven-3.6.1/bin/mvn
  1. Now, you need to verify that the installation was successful by running mvn -v in the terminal.

Maven bash auto-completion

Once you complete apache maven installation, if you like bash auto-completion feature, check out the maven bash auto-completion project on GitHub.