Apache Maven – introduction to automated project development (part 1)

Apache Maven – introduction to automated project development (part 1)

Apache Maven is an automator for compiling Java projects

Good afternoon Habre, in this article we will analyze one of the Apache Maven project collectors. Let’s start by installing, configuring and building our first project.

Apache Maven – is a framework for automating and compiling Java projects. Usually just called Maven.

You can always find the most detailed information on the official website Maven.

And the central Maven repository where everything you need to work with Maven is collected. I will explain how to use it a little later.

Maven Repository

Installing Maven on Windows 10

To work, you need to install Maven on your computer, so go to the official Maven website Binary zip archive at the time of writing, the major version was Maven 3.9.3. But before etit, make sure that you have it installed on your computer JDK

JDK check Windows 10

Open the command line and write the command:

java -version

If you see text like this, the JDK has been successfully added to the Windows environment variables

Apache Maven 3.9.3

Excellent, we have the JDK, we downloaded the archive from Maven, we can proceed with the installation:

  1. We create a folder where we will unpack Maven, you can choose any name, but preferably in Latin letters and No gaps example: “Maven_3.9.3so you will eliminate some of the errors that may occur;

  2. We unpack the downloaded archive into the created folder;

  3. Add the path to the folder to the Windows environment variables:

Let’s go to the Windows environment variables, we will work with the upper window. We need to create 3 variable-value pairs and change “Path”

We write down the values ​​from the table below

Variable (here by standard)

Value (you show your way!)

M2

%M2_HOME%\bin (leave as is here)

M2_HOME

C:\Program Files\Java\Maven_3.9.3

JAVA_HOME

C:\Program Files\Java\jdk-17\

And finally, we change “Path”: we just create a new value.%M2%“press OK”

We check that we have done everything correctly, here it is similar to checking the JDK:

mvn -version

If you got this answer, congratulations, you and I have installed Apache Maven on Windows 10

Maven installation successful

Installing Maven on Linux

Everything is surprisingly easier with Linux

sudo apt update
sudo apt install maven
mvn -version

Positive answer

Conclusion: In the first article, we detailed the installation of Apache Maven for two types of operating systems and prepared our environment for work.

In the next part, we’ll look at some pom.xml examples and the tools Maven provides.

Related posts