What you need before you start

Maven is a build tool for Java projects that manages dependencies and automates compilation. To install it on Windows, you need Java already installed on your machine — Maven cannot run without it. Check whether you have Java by opening Command Prompt and typing java -version. If you see a version number, you are ready. If not, download and install the Java Development Kit (JDK) from Oracle's website first.

You will also need to know where Java is installed on your system. During the JDK installation, Windows typically places it in C:\Program Files\Java\jdk-[version] or C:\Program Files (x86)\Java\jdk-[version]. Write down this path — you will need it later.

Key Takeaways

  • Maven requires Java to be installed first; verify this by typing java -version in Command Prompt.
  • Download Maven from apache.org, extract the folder to a location like C:\Maven, and note the full path.
  • Add Maven's bin folder to your Windows PATH environment variable so you can run Maven commands from any directory.
  • Test the installation by opening a new Command Prompt window and typing mvn -version to confirm Maven is working.

Download and extract Maven

Go to maven.apache.org and navigate to the Downloads section. Look for the latest stable release under "Files" — you want the file named something like apache-maven-3.9.x-bin.zip (the exact version number changes, but the pattern stays the same). Download the .zip file to your computer.

Once the download finishes, right-click the .zip file and select Extract All. Windows will ask you where to extract it. Choose a simple location without spaces in the path — C:\Maven works well. After extraction, you should see a folder named apache-maven-3.9.x (or whatever version you downloaded) inside your chosen location. The full path might look like C:\Maven\apache-maven-3.9.x.

Set the JAVA_HOME environment variable

Windows needs to know where Java is installed. Open the Start menu and search for Environment Variables. Click Edit the system environment variables. In the window that opens, click the Environment Variables button near the bottom right.

Under "System variables," click New. In the Variable name field, type JAVA_HOME. In the Variable value field, paste the path to your JDK installation — for example, C:\Program Files\Java\jdk-21.0.1 (use your actual version number). Click OK.

Add Maven to your PATH

In the same Environment Variables window, find the variable named Path in the System variables list and click it. Then click Edit. A window will open showing all the directories in your PATH, one per line.

Click New and type the full path to Maven's bin folder. If you extracted Maven to C:\Maven\apache-maven-3.9.x, you would type C:\Maven\apache-maven-3.9.x\bin. Click OK, then OK again to close the Environment Variables window.

Verify the installation

Close any Command Prompt windows you have open, then open a new one. This ensures Windows loads your updated PATH. Type mvn -version and press Enter. If Maven is installed correctly, you will see output showing the Maven version, Java version, and other system details.

If you see an error like "mvn is not recognized," the PATH was not set correctly. Go back to the Environment Variables window, double-check that you typed the bin folder path exactly right, and make sure there are no extra spaces at the beginning or end. Close Command Prompt and open a new one to test again.

Troubleshooting common problems

If Maven runs but Java is not found, check that JAVA_HOME points to the correct JDK folder. Type echo %JAVA_HOME% in Command Prompt to see what path Windows is using. It should point to a folder containing a bin subfolder with java.exe inside. If it does not, update JAVA_HOME in Environment Variables.

If you installed a 32-bit JDK but have a 64-bit Windows system (or vice versa), Maven may not work. Check your JDK version by typing java -version. If it says "32-bit" or "64-bit," make sure it matches your Windows installation. You can find your Windows version by right-clicking This PC and selecting Properties.

What to do after installation

Once Maven is working, you can create a new project or work with an existing one. Maven projects use a file called pom.xml in the project root directory. To build a project, navigate to that directory in Command Prompt and type mvn clean install. Maven will download dependencies and compile your code.

If you are new to Maven, the official documentation at maven.apache.org has guides on project structure and common commands. Most development environments like Eclipse and IntelliJ IDEA also include Maven support built in, so you may not need to use Command Prompt once you set up a project in an IDE.

Frequently Asked Questions

Do I need to restart my computer after setting environment variables?

No, but you do need to close and reopen Command Prompt. Windows loads environment variables when a new Command Prompt window starts, so closing all open prompts and opening a fresh one is enough.

What if I have multiple Java versions installed?

JAVA_HOME should point to the version you want Maven to use. If you have both Java 11 and Java 21 installed, set JAVA_HOME to whichever one your projects need. You can change it anytime by editing the environment variable.

Can I install Maven in Program Files?

Yes, but paths with spaces can sometimes cause problems. If you do install it there, make sure the full path in your PATH variable is correct and has no typos. A simpler approach is to extract Maven to C:\Maven or another root-level folder without spaces.

How do I know if Maven is using the right Java version?

Type mvn -version in Command Prompt. The output will show which Java version Maven is using. If it is not the version you expected, check that JAVA_HOME points to the correct JDK folder.

What does the bin folder in Maven contain?

The bin folder holds the executable files Maven needs to run, including mvn.cmd (the Windows command) and mvn.bat (the batch file). Adding this folder to PATH lets you type mvn from any directory instead of typing the full path every time.