How to Install Maven 3 on Ubuntu 16.04
What Is Maven
Maven is a build tool. It is great at building Java projects. Maven doesn’t act alone – its power is about bringing a lot of tools together to effect the build.
It unites compilers, dependency managers, unit test managers and coverage reporting tools, packagers, javadoc producers and so on.
Maven’s greatest power – and the feature that sets it apart from its predecessor ANT, is its central repository. The Maven2 central repository aggregates every useful java library under its roof. With ANT you need to download and place your own jar files. Maven does this for us.
Maven has popularized a neat feature called “archetypes”. With one command, Maven will create a full Java project including the Maven build POM file, resources, unit tests and starter files. Archetypes exist for basic jar type projects to WAR (Web Archive) and EAR (Enterprise Archive) projects.
Ant is the legacy competitor. Maven and Ant are both from the Apache stables. Ant’s vast popularity makes its demise a long drawn out affair. If you are starting out on a greenfield project, make the jump to Maven. Your productivity will soar by at least 30% (at times up to 40%).
If you use Scala, Play2 or Akka, SBT will be the build tool of choice. Git‘s build process is also in direct competition with Maven. Another popular build tool is Gradle.
You need to install maven if you
- are building or creating Java projects in an IDE
- are building Java projects on the command line.
- are using Continuous Integration tools like the Jenkins CI Server
- want to access its vast plugin base
Install Maven with this simple command.
sudo apt-get install maven
Then test it with the command
The reply should be something like this.
Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_91, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_GB, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-31-generic", arch: "amd64", family: "unix"