To install Apache Maven 3.9.
7 on a Windows system, follow these steps:
### Step 1: Download Apache Maven
1. Go to the [Apache Maven download
page](https://maven.apache.org/download.cgi).
2. Under "Files" section, find the link to the binary zip file for Maven 3.9.7
(`apache-maven-3.9.7-bin.zip`).
3. Click on the link to download the zip file.
### Step 2: Extract the Archive
1. Once the download is complete, navigate to the downloaded zip file location.
2. Right-click on the `apache-maven-3.9.7-bin.zip` file and select "Extract All..."
or use an extraction tool like WinRAR or 7-Zip to extract the contents.
3. Extract the contents to a directory of your choice, for example: `C:\Program
Files\Apache\Maven\apache-maven-3.9.7`.
### Step 3: Set Up Environment Variables
1. Open the Start Menu and search for "Environment Variables". Select "Edit the
system environment variables".
2. In the System Properties window, click on the "Environment Variables..."
button.
3. In the Environment Variables window, under the "System variables" section,
click on "New..." to create a new environment variable.
**M2_HOME:**
- Variable name: `M2_HOME`
- Variable value: `C:\Program Files\Apache\Maven\apache-maven-3.9.7`
4. Add another new environment variable.
**MAVEN_HOME:**
- Variable name: `MAVEN_HOME`
- Variable value: `C:\Program Files\Apache\Maven\apache-maven-3.9.7`
5. Edit the `Path` system variable to include the Maven `bin` directory:
- Find and select the `Path` variable in the "System variables" section, then
click on "Edit...".
- In the "Edit Environment Variable" window, click "New" and add the following:
```
%M2_HOME%\bin
```
### Step 4: Verify the Installation
1. Open a new Command Prompt window to ensure the new environment
variables are loaded.
2. Type the following command to verify the Maven installation:
```sh
mvn -version
```
3. You should see output similar to this:
```sh
Apache Maven 3.9.7 (bbb0cc2a67e4f7f0cbd4e1c9189e696a26d188c7)
Maven home: C:\Program Files\Apache\Maven\apache-maven-3.9.7
Java version: 1.8.0_271, vendor: Oracle Corporation, runtime: C:\Program Files\
Java\jdk1.8.0_271\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
```
If you see a similar output, then Maven has been successfully installed on your
Windows system.
### Troubleshooting
- Ensure that the `JAVA_HOME` environment variable is also set correctly, as
Maven requires a valid Java installation. The `JAVA_HOME` variable should point
to your JDK installation directory, such as `C:\Program Files\Java\jdk1.8.0_271`.
- If you encounter issues, make sure you have closed and reopened the
Command Prompt window to reload the environment variables.
By following these steps, you should be able to install Apache Maven 3.9.7 on
your Windows system.