Here are the steps to install Maven on Windows:
- Download Maven from the Apache Maven website (https://maven.apache.org/download.cgi).
- Unzip the downloaded archive file to a directory of your choice. For example, you can extract it to
C:\Program Files
. Here’s what the unzipped directory should look like: - Set the
M2_HOME
environment variable to point to the directory where you have unzipped Maven. To do this, open the Start menu and search for “environment variables”. Click on “Edit the system environment variables”. - In the “System Properties” window that opens, click on the “Environment Variables” button.
- In the “Environment Variables” window that opens, click on the “New” button under “System variables”.
- In the “New System Variable” window that opens, enter
M2_HOME
as the variable name and the path to the directory where you have unzipped Maven as the variable value. For example, if you have extracted Maven toC:\Program Files\apache-maven-3.8.1
, you should enterC:\Program Files\apache-maven-3.8.1
as the variable value. - Click “OK” to close all the windows.
- Add the
bin
directory of Maven to your system’sPATH
environment variable. To do this, open the Start menu and search for “environment variables”. Click on “Edit the system environment variables”. - In the “System Properties” window that opens, click on the “Environment Variables” button.
- In the “Environment Variables” window that opens, find the “Path” variable under “System variables” and click on “Edit”.
- In the “Edit Environment Variable” window that opens, click on “New” and enter the path to the
bin
directory of Maven. For example, if you have extracted Maven toC:\Program Files\apache-maven-3.8.1
, you should enterC:\Program Files\apache-maven-3.8.1\bin
. - Click “OK” to close all the windows.
- Verify the installation by opening a new command prompt window and running the command
mvn -version
. This command should display the version of Maven you have installed.
Congratulations, you have successfully installed Maven on Windows!
Leave a Reply