
Helpdice Team
How to install Maven in Linux OS
Direct Installation:
We can use the yum repository to directly install the maven in our system
yum install maven
Alternative of Yum
Download Apache Maven
Start by downloading the Apache Maven in the using the following wget command:
wget https://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
Extract the tar file using the folllowing command:
tar xf apache-maven-3.5.4-bin.tar.gz
Setup environment variables
Next, we’ll need to set up the environment variables. Open your text editor and create a new file named maven.sh inside of the /etc/profile.d/ directory.
vi /etc/profile.d/maven.sh
First enter i to get in the insert mode
Paste the following lines:
export M2_HOME=/usr/local/src/apache-maven
export PATH=${M2_HOME}/bin:${PATH}
Afer pasting the code press ESC then :wq for quit and save
Make the script executable by running the following chmod command:
sudo chmod +x /etc/profile.d/maven.sh
Load the environment variables using the source command:
source /etc/profile.d/maven.sh
Verify the installation
To verify that Maven is installed, use the mvn -version command which will print the Maven version:
mvn --version
That's All.
Thank You