Install Multiple Apache Maven on Linux Ubuntu


Hi, in this case I would like to share a little bit knowledge looks like previous article, it`s about multiple installation of Apache Maven based on linux os, and I use Linux Ubuntu OS v-18.04 LTS, or you can use another linux version.


Download Apache Maven v3, click here.

In this case I use Apache Maven v-3.6.3 and Apache Maven v-3.8.4

Because we were using linux os, so download those files with extension .tar.gz

If you want to get the latest version of Apache Maven, click here.


In your path ~/Downloads you will have 2 files of Apache Maven.

  • apache-maven-3.8.4-bin.tar.gz
  • apache-maven-3.6.3-bin.tar.gz


Create new folder by following this command.

$ sudo mkdir -p /usr/lib/apache


Next, you can move or copy-paste those files into /usr/lib/apache

$ sudo cp -r apache-maven-3.8.4-bin.tar.gz /usr/lib/apache

$ sudo cp -r apache-maven-3.6.3-bin.tar.gz /usr/lib/apache


Now, move to /usr/lib/apache by typing

$ cd /usr/lib/apache


Extract each files.

$ sudo tar xvzf apache-maven-3.8.4-bin.tar.gz

$ sudo tar xvzf apache-maven-3.6.3-bin.tar.gz


You will have each folder by each Apache Maven versions.


The question is. How to install those Apache Maven one by one?


Follow these steps bellow for Apache Maven v-3.6.3

$ sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/usr/lib/apache/apache-maven-3.6.3/bin/mvn" 20222363

$ sudo update-alternatives --set mvn /usr/lib/apache/apache-maven-3.6.3/bin/mvn


Follow these steps bellow for Apache Maven v-3.8.4

$ sudo update-alternatives --install "/usr/bin/mvn" "mvn" "/usr/lib/apache/apache-maven-3.8.4/bin/mvn" 20222384

$ sudo update-alternatives --set mvn /usr/lib/apache/apache-maven-3.8.4/bin/mvn


Finally, choose one version.

$ sudo update-alternatives --config mvn

Follow guide on your screen.

and, don`t forget to check.

$ mvn --version


Test on your SpringBoot project one, click here.



Done. Good luck! 😂

I hope this article can help your problem or fixed your knowledge.

See you on the next one.


Source :

https://maven.apache.org/download.cgi

https://dlcdn.apache.org/maven/maven-3/

https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/

https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/

https://git-maspaad.blogspot.com/2022/02/install-multiple-jdk-on-linux-ubuntu.html

https://git-maspaad.blogspot.com/2021/03/springboot-with-apache-maven.html

Comments