Contents
Description
This post will show you to install and configure maven on Windows, Linux and Mac. Before performing the installation, make sure the Java Development Kit is properly installed and configured. For Linux you can refer to my post
Linux
For this installation I have performed the task on Debian 10 64 bit, but also referred the same for other distros, it all turned out to be working perfectly. You can use the manual way to perform installation on other distros. For this make sure the java
Installing using the Package Manager
sudo apt install maven
Installing Manually
Navigate to Apache Maven’s official web site and and download the latest version (3.6.3 as of writing this article) the binary tar.gz package.
1. Unpack the Tar file
tar zxvf apache-maven-3.6.3-bin.tar.gz
2. Move the folder to the opt folder
sudo mv apache-maven-3.6.3 /opt/
3.Create a Maven profile file
sudo nano /etc/profile.d/maven.sh
3.1. Add these lines in the “.sh” file
export M2_HOME=/opt/apache-maven-3.6.3 export PATH=${M2_HOME}/bin:${PATH}
4. Make the file executable and Reload the “sh” file in the system
sudo chmod +x /etc/profile.d/maven.sh source /etc/profile.d/maven.sh
5. Check the Maven installation
mvn --version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /opt/apache-maven-3.6.3 Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_221/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.19.0-8-amd64", arch: "amd64", family: "unix"
Windows
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