Installing Maven on Linux, Windows and Mac

Here in this post i will show you how to install and configure maven on such operating systems. First of all I will start out with linux, in all distributions you can use the same way since the kernel is the same. So there are 2 ways to achieve this installation on linux, first of all you may use your distro package manager to install it easily or do it manually, for automation to use ubuntu package manager the code goes this way:


Shorthand on ubuntu

sudo apt-get install maven

Manual Installation(Tested on Fedora 28 Mate Spin)

This will install and configure maven on ubuntu, but you will not have the latest version. for the latest version navigate to Apache Maven’s official web site and and download the latest version (3.1.1 as of now) the binary tar.gz package.

when we are all good to go towards the installation lets get started, launch terminal and issue the commands:

tar -zxvf apache-maven-3.5.3-bin.tar.gz 
sudo mv apache-maven-3.1.1 /opt/ 
sudo nano /etc/profile.d/

and add these lines in the “.sh” file

export M2_HOME=/opt/apache-maven-3.5.3 
export M2=$M2_HOME/bin 

Refresh the files:

source /etc/profile.d/
. /etc/profile.d/


if you name your file different way then do not forget to change the address. so by now with the manual or package manager installation we are done. so lets give it a try on terminal and see how it goes:

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00)
Maven home: /opt/apache-maven-3.5.3
Java version: 1.8.0_172, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_172/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.16.3-301.fc28.x86_64", arch: "amd64", family: "unix"


Download the binary file in .zip or tar.gz does not matter extract the folder under C drive if you want you may create the folder wherever you want, but to make it easier you shall consider practical way of it, after you extract the folder

Right Click Computer and click on Properties


On the left side of the properties, click on Advanced system settings


Below click on Environment Variables


Click on “New” on Users variables and enter the details as below


and on system variables find PATH and add the line


and now lets launch command line and see if its configured


Mac OS

Normally maven comes out of package on mac os operating systems since 10.6.8 Snow Leopard, test if the maven is installed on your mac launch terminal and enter the command:

mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 19:31:09+0200)
Maven home: /usr/share/maven
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"
Tugruls-Mac:~ tugrulaslan$

to install it manually as the above linux package file download and exract the file the same way

tar -zxvf apache-maven-3.1.1-bin.tar.gz
sudo mv apache-maven-3.1.1 /usr/lib/maven
vim ~/.bash_profile

and these lines

export M2_HOME=/usr/lib/maven
export PATH=$PATH:$M2_HOME/bin

before you proceed the maven installation, please make sure that you have successfully carried out jre and jdk installation and configuration

Leave a Reply

Your email address will not be published. Required fields are marked *