Apache Maven is the most popular project management tool for Java applications. We can install maven on any operating system.

Installing Maven on Windows

Maven requires JDK to execute. Maven 3.3+ requires JDK 1.7 or above to execute. Let’s look into the various steps to install Maven on Windows.

1. Install JDK on Windows

We can install Oracle JDK using the executable file. But, for this tutorial, we will install OpenJDK. OpenJDK is free to use and we don’t need to worry about licenses or to pay Oracle for support.

If you want to install Oracle JDK on Windows, follow this tutorial: Java Windows Download Install

1.1) Download OpenJDK Binaries ZIP File

Go to the JDK Download URL: https://jdk.java.net/13/

Download the binaries for Windows/x64 as shown in the below image.

download-openjdk-windows

 

Download OpenJDK for Windows

Extract it to any place you want. I have extracted it to C:Program FilesJava folder.

1.2) Setting up Environment Variables – JAVA_HOME and Path

We have to set JAVA_HOME and add the JDK binaries folder to the Path variable.

You can search for “edit environment variables” or go to “Control Panel -> System and Security -> System” and click on the “Advanced system settings” link in the left sidebar.

In the “System Properties” popup, go to the “Advanced” tab and click on the “Environment Variables” button. This will open a new popup window to edit user and system environment variables.

Now, create a new system environment variable “JAVA_HOME” with value as the location of the JDK folder.

Also, add the JDK bin folder to the Path variable list of directories.

Windows Set Java Home Path Variable

1.3) Verifying Java Installation through Command Prompt

Open the command prompt and type java -version command. It should print the JDK version installed by you.

download-openjdk-windows

 

Check Java Version Command Prompt

2. Install Maven on Windows

Once the JDK is properly installed and configured, we can move ahead with the installation of the maven.

2.1) Download Maven Binary zip Archive

Go to the URL: https://maven.apache.org/download.cgi

Download the “Binary zip archive” as shown in the below image.

 

Download Maven Binary Zip Archive

2.2) Setting up Maven Environment Variables – M2_HOME, MAVEN_HOME, Path

First of all, extract the downloaded maven zip file to any folder of your choice. I have extracted it to C:Program Filesapache-maven-3.6.3.

Now, use the below image to create the M2_HOME and MAVEN_HOME variables. Also, add the maven bin folder to the Path variable.

setting-maven-environment-variables

 

Setting Maven Environment Variables

2.3) Verifying Maven Installation through Command Prompt

Open command prompt and type mvn -version command. It should print the maven version, maven bin folder location, and the Java version it’s using.

checking-maven-version-command-prompt

 

Checking Maven Version Command Prompt

That’s it. Maven is successfully installed and you can use it to create and manage Java projects.

References

By admin

Leave a Reply

%d bloggers like this: