Maven includes dependency management, such that any direct and indirect dependencies to the primary JAR files will be automatically downloaded and any conflicts resolved. This article covers the basics of downloading and installing Maven.
Where do I download Maven?
I have downloaded the latest version of Apache Maven from
I prefer not to use apt to install maven. The package manager will attempt to download OpenJDK and run this in combination with Maven. Probably nothing wrong with this approach, but I don't prefer it.
Where should I install Maven?
If you are not familiar with the Linux directory layout, this article is recommended:
My preferred path is:
This leaves opportunty to distinguish between various apache binaries and maven versions. How do I install Maven? Typically, the file will be downloaded to your “downloads” folder in your home directory.
Using a terminal, following these steps:
Create the Directory Path:
This creates the directory path for the new installation. The -p flag creates the directory hierarchy. You will need to run this command as the super user (su + do = sudo).
Move the File:
Moves the downloaded file to the installation path.
Unzip the File:
Navigates to the newly created folder, and unpacks the downloaded file.
Setting the PATH
I recommend setting the path in the /etc/environment file. This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line.
and once completed, I have this:
To activate these path variables for the current terminal session, type
If your path variables were set successfully, you should be able to type
in the terminal window and get back something that looks like this:
This entire process can be automated in a single shell script: