How to Install Maven on a Linux Server
Maven and JDK
Maven is one of the build tools used for creating packages from Java-based codes.
One of the dependencies required for Maven is Java Development Kit. Unlike other Java-based applications, that are not build tools, the JRE (Java Runtime Environment) will work but only JDK will work with Maven and other build tools.
Confirmation that you have JDK can be obtained by running the command below… The Java compiler will help convert Java codes from human-readable format to machine-readable format.
javac -version
The version requirement of Java may change from time to time. Click here to see Oracle’s documentation on the different versions of JDK that can be installed.
If you just want the install JDK on a Debian distribution and you are not concerned about a particular version, run sudo apt-get install default-jdk.
To install on distributions that use the yum package manager, run any of the following:
sudo yum install java-11-openjdk-devel
#This will install Java 11 JDK
sudo yum install java-1.8.0-openjdk-devel
#This will install Java 8 JDK
Installing Maven…
Here are the steps for installing Maven on your Linux server:
- Visit the Apache Maven website to download the latest version of Maven. You can use the wget command to download it. If you don’t have wget in your server, of course, you need to install it.
- Extract the downloaded archive to the directory where you want Maven installed. You need unzip installed to make this happen.
- Add the following lines to your ~/.bashrc file to set the environment variables for Maven (don’t forget to replace “
enterTheAbsolutePathToYourMavenHomeDirectory
” in the code)…export M2_HOME=enterTheAbsolutePathToYourMavenHomeDirectory
export PATH=$PATH:$M2_HOME/bin Run the source command to reload the ~/.bashrc file:
source ~/.bashrc
Confirm the version of maven you have installed by running the command below:
mvn -v
Do you want to become a tech pro? Learn DevOps with us at BecomeATechPro.com. Interested in engaging tech talents for your projects, click here to source tech talents.
BecomeATechPro.com is indeed a very clear path to becoming a very skilled Dev0ps Engineer. I’m excited to be a student with the institute.
Thank you very much for your kind words. We are very proud and excited about what the future holds for you.