A step by step guide on how to install Maven on Linux Ubuntu Operating Systems manually and from Command line.
Make sure Java JDK installation 1.7 or higher OR GraalVM for Java 8 or higher installed in your system and already set JAVA_HOME system path.
1. Install Maven on Ubuntu using apt
1.1. There are several ways you can install Maven on Linux. Run command sudo
apt install maven to install Maven along with Java on Linux Ubuntu, it will get the latest maven distribution.
$ sudo apt install maven
1.2. Testing Installation:
$ mvn -version Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.4.0-40-generic", arch: "amd64", family: "unix"
2. Alternate way to install Maven on Linux Ubuntu
Make sure already Java JDK or GraalVM setup done on your Linux Machine.
2.1. Download binary tar archive from apache-maven-3.xxx-bin.tar.gz, extract it in your local system.
$ wget -P /home/ubuntuadmin/Documents/ "https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz"
$ cd /home/ubuntuadmin/Documents/ $ tar xz -f apache-maven-3.6.3-bin.tar.gz
2.2. Create MAVEN_HOME variable and update $MAVEN_HOME/bin to PATH. To update them on Linux Ubuntu run following commands.
$ sudo nano ~/.bashrc OR sudo gedit ~/.bashrc (on desktop version)
Include the following lines at the end to the .bashrc file.
MAVEN_HOME="/home/ubuntuadmin/Documents/apache-maven-3.6.3" PATH="$MAVEN_HOME/bin":$PATH
2.3. Test the Maven Installation on Ubuntu using mvn -version
.
3. Conclusion
In this guide we have seen how to install Maven on Ubuntu OS manually and from Command line. Did it work for you or any issue comment below.
Other Maven Setups:
- Install Maven on Windows
- Install Maven on Mac
- Import maven project into Eclipse
- Maven Skip Tests
- Maven run single test
- Maven set java version
- Maven run java main class