How to Install Apache Maven

With this article, we will look into how to install Apache Maven on your machine. Maven, a project management and comprehension tool which provides a way to build and manage Java-based applications. Since Maven is used for building JVM programs, you need to have Java installed in the system prior to setting up Apache Maven. The Maven project includes a ZIP file that consists of a pre-compiled version of Maven. Installation of Maven is very simple and can do by extracting the archive and adding it to the bin folder with the mvn command to shell PATH. 

Installing Maven on Windows Operating System

Follow the steps mentioned below to install Apache Maven on Windows OS.

  • Visit Apache Maven’s website to download the latest version of the ZIP file.
  • Unzip the file to the folder where we want to use Maven.
  • Add Maven to the environment path by following the steps
  • Using system properties add M2_Home and Maven_Home variables to the environment.
  • Then make it point to the Maven folder, where we have extracted the file.
  • Append the Maven bin folder – %M2_HOME%\bin– in order to update the path variable. This allows us to run the Maven command anywhere we want.
  • Now as a final step, verify the Maven installation by running the command mvn -version from the command prompt.

Installing Maven on Unix-based Operating System (Linux, Solaris) Tips

Follow the steps mentioned below to install Apache Maven on Linux.

  • Visit Apache Maven’s website to download the latest version of Apache Maven file (tar.gz file).
  • Extract those files to the folder where we want Maven to be used.
  • By running the command, you can set the environment variable. Here we are considering the download file version to be “apache-maven-3.8.2-bin.tar.gz

          export M2_HOME=/usr/local/apache-maven/apache-maven-3.8.2

         export M2=$M2_HOME/bin

          export MAVEN_OPTS=-Xms256m -Xmx512m

  • By running the below command, append the M2 variable.

         export PATH=$M2:$PATH

  • Now as a final step, verify the Maven installation by running the command mvn -version in the terminal.

The Benefits of Maven

  • More consistent project structure – All Maven projects have a common structure, which makes it easier to understand each project.
  • Better dependency management.
  • More powerful builds, Better debugging.
  • Better collaboration and Reduced duplication.

Conclusion

With this article, we discussed some of the ways on how to install Apache Maven on various OS. Maven helps to simplify creating processes in the Jakarta Turbine project. There were many projects and each project contained slightly different ANT build files.

The Apache team, developed Maven to build multiple projects, publish project information, deploy the projects, share JARs across all projects and help to the collaboration of the teams.

To summarize, Maven disentangles & standardizes the build process and it handles the documentation, distribution, compilation, and team collaboration tasks seamlessly.

About ServerAdminz

We are A Premium Server Management Company, specialized in 24/7 Outsourced Web Hosting Support, Outsourced server support, Linux, Windows, Game, cPanel Server Management, Helpdesk Support, Application development services, Remote Infrastructure Management, NOC support, Cloud Support, and Enterprise Security Services. Our support engineers are available 24/7 to assist you in case of any emergencies or issues.

Related Article

How To Harden A cPanel Installed Apache Web Server?

What is Apache CloudStack?