Installing apache maven is a relatively short process composite on basic 4 steps. After undergoing these 4 steps you can avail all the benefiting features of apache Marven to ably manage the java projects on your Ubuntu.
Step# 1: Package Upgradation
Step# 2: Installation of Apache Maven
Step# 3: Setting-up environmental variables of apache maven.
Step# 4: Verification
It is necessary to have a java system installed in your server along with the development kit of java encompassing JDK, and JRE to run the command of maven. If you don’t have these systems installed, then implement this command.
$ sudo apt install default-jdk
You can verify the installation of the java system and its kit using.
Update the existing package using sudo apt command. It is fundamental to update your existing packages before installing any tool or server on the ubuntu to effectively run it.
You can also run this command before installing the java kit, that way your system packages will be updated along with the installation of the kit.
There are primarily two methods to install an apache maven in your system. you can either download it with the apt command or directly from its web source through the wget command.
If you are inclined towards downloading it from the webserver to get the latest version of apache maven, then apply the wget command.
$ sudo wget https://www-eu.apache.org/dist/maven/maven-3/3.6.3/binaries/
Now extract the downloaded maven from the tmp directory to opt directory.
$ sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
If you wish to have prominent control over maven then you can also generate a link symbolizing the maven directory by applying the following code.
$ sudo ln -s /opt/apache-maven-3.6.3 /opt/maven
For simply extracting the downloaded maven without changing its directory use the following commands
$ sudo tar xzf apache-maven-3.6.3-bin.tar.gz
$ sudo ln -s apache-maven-3.6.3 maven
Setting-up environmental variables of apache maven
To set the environmental variables of apache maven you will be required to create a file for those variables. Implement the following commands to generate a new file.
$ sudo vi /etc/profile.d/maven.sh
Now to set up variables in that file apply.
$ source /etc/profile.d/maven.sh
To simply verify the installation of Apache on your Ubuntu 20.04 apply mvn command as follows:
And lastly, clean up your disk for nifty performance by clearing the archives where you downloaded the maven.
$ sudo rm -f apache-maven-3.6.3-bin.tar.gz
Installing apache maven on Ubuntu 20.04 is feasible and doesn’t need lengthy and complex commands. If you already have a java kit installed in your system, then the installation process will become more platen and convenient. Following the above-mentioned step-by-step process for installation, you won’t face any complex errors. If you are installing some other latest version rather than 3.6.3 of the apache Maven then apply the commands that involve the description of the version carefully.