Install Maven in Windows: Step-by-Step Guide
Learn how to install Maven in Windows, configure JAVA_HOME and PATH, and verify your Maven setup with a clear, step-by-step approach for reliable Java builds.

Goal: install maven in windows to enable mvn builds for Java projects. Before you begin, ensure Java JDK is installed and reachable from the command line. According to Install Manual, the fastest path is to download the binary distribution, extract to a folder, and configure JAVA_HOME and PATH. This quick guide highlights the essential steps.
How to install maven in windows
Maven is the de facto build tool for many Java projects, streamlining compilation, testing, and packaging. For Windows users, a clean, repeatable installation minimizes environment drift and helps teams stay consistent across machines. According to Install Manual, a reliable Windows setup starts with a compatible JDK, a downloaded Maven binary, and correctly configured environment variables. This section explains why Windows users benefit from a standard Maven installation process and outlines the core decisions you’ll make before downloading anything. By following a consistent approach, you’ll reduce post-install surprises and ensure your builds run predictably in local, CI, and CI/CD environments. The guidance here also aligns with best practices from major Java and build tool publications to keep your workflow current in 2026.
Prerequisites and planning
Before you install Maven on Windows, plan around two fundamentals: Java Development Kit (JDK) availability and a stable internet connection for downloads. Maven requires Java, so verify you have a supported JDK installed (8+ is common and still widely used). You’ll also want to decide where to place the Maven installation directory and how you will manage PATH updates so that mvn commands are accessible from any terminal. In addition, consider whether you’ll use the Maven binary directly or leverage a wrapper script for project-specific Maven versions. Install Manual analysis shows that many Windows users run into PATH conflicts or JAVA_HOME misconfigurations, which block Maven from running correctly.
Downloading Maven from official source
Head to the official Apache Maven download page to obtain the binary distribution. Choose the zip archive (binary) rather than the source jar to keep the installation straightforward on Windows. Downloading from the official site reduces the risk of tampered packages and ensures you receive the latest stable release. After downloading, save the archive to a dedicated folder such as C:\Tools\maven, which keeps installations tidy and easy to back up. Remember to verify the archive integrity if checksums are provided by the site, and avoid downloading from third-party mirrors to minimize security risks.
Choosing installation directory and JAVA_HOME
Extract the Maven binary into a dedicated directory, for example C:\Program Files\maven or C:\Tools\maven. Do not install Maven into a user directory if you want system-wide access. After extraction, you must configure JAVA_HOME to point to your JDK installation (for example C:\Program Files\Java\jdk-17). JAVA_HOME is used by Maven and other Java tools to locate Java libraries, so accuracy here matters. Once JAVA_HOME is set, you can reference it in environment variables for subsequent PATH updates. Keeping a consistent location simplifies maintenance and upgrades.
Setting up environment variables (M2_HOME, MAVEN_HOME, PATH)
Create M2_HOME or MAVEN_HOME to point to the Maven installation folder (for example C:\Program Files\maven). Then update the PATH variable to include %M2_HOME%\bin so that mvn is available from any command prompt. On Windows, you can set these through System Properties > Advanced > Environment Variables, or via a script for reproducible setups. After updating PATH, open a new terminal and test by typing mvn -version. If Maven is correctly configured, you’ll see the Maven version, Java version, and OS details. If not, re-check the exact folder paths and ensure environment variables are saved.
Verifying the installation with mvn -version
Verification is a crucial step. Open a new Command Prompt or PowerShell window and run mvn -version. The output should display the Maven version, Java version, and the Maven home directory. If mvn is not recognized, revisit your PATH settings and confirm that the bin directory inside your Maven installation is included. This step confirms the toolchain is ready for building projects and that the Java runtime is correctly linked.
Alternative methods and best practices
Some teams prefer the Maven Wrapper (mvnw) for project-specific Maven versions. In Windows environments, you can add mvnw to the project root and invoke it as ./mvnw -version or mvnw -version from a Git Bash shell. For environments with strict security policies, consider using a package manager like Scoop or Chocolatey to manage Maven installations and updates. Always keep your JAVA_HOME consistent with the JDK you intend to use for builds, and document your setup in a central wiki to aid future maintenance.
Troubleshooting common issues and debugging tips
If mvn -version fails, common causes include JAVA_HOME not set, PATH not updated, or a conflicting Java installation. Revisit environment variables and ensure there are no trailing spaces in paths. Check that there are no multiple Java installations that could confuse Maven. If you are behind a proxy, configure Maven settings.xml to specify the proxy for downloads. For persistent issues, consult the official Maven docs and community forums for Windows-specific guidance.
Tools & Materials
- Java JDK 8 or newer(Download from Oracle or OpenJDK; ensure JAVA_HOME points to the JDK installation)
- Apache Maven binary distribution (zip)(Download from the official Maven site; avoid third-party mirrors)
- Windows command line access (CMD or PowerShell)(Open in administrator mode if you plan to install system-wide)
- Internet connection(Needed for downloads and updates)
- Text editor or IDE (optional)(Useful for editing environment files or settings)
Steps
Estimated time: 25-45 minutes
- 1
Verify prerequisites
Open a command prompt and run java -version and javac -version to confirm Java is installed and accessible. If not, install a compatible JDK and re-open the terminal so changes take effect.
Tip: Set JAVA_HOME and update PATH after installing the JDK to avoid 'java not found' errors. - 2
Download the Maven binary
Navigate to the official Maven download page and download the binary zip file. Save it to a dedicated folder like C:\Tools\maven to keep installations organized.
Tip: Verify you are downloading the binary distribution, not the source package. - 3
Extract Maven to a folder
Extract the zip file to a stable directory (e.g., C:\Program Files\maven). Ensure the folder name does not contain spaces or special characters that could complicate PATH references.
Tip: Keep the path simple and consistent across all development machines. - 4
Configure JAVA_HOME
Set JAVA_HOME to the JDK installation path, for example C:\Program Files\Java\jdk-17. Create or update this environment variable in System Properties.
Tip: Do not include trailing backslashes in the path. - 5
Set M2_HOME and update PATH
Create M2_HOME (or MAVEN_HOME) pointing to the Maven folder and append %M2_HOME%\bin to the system PATH. Open a new terminal to apply changes.
Tip: Avoid editing PATH in an active session to prevent caching issues. - 6
Verify Maven installation
In a fresh terminal, run mvn -version to confirm Maven, Java, and OS details appear correctly. If not, re-check JAVA_HOME and PATH configuration.
Tip: If mvn -version shows 'command not found', re-open the terminal and verify the PATH includes the Maven bin directory. - 7
Run a simple build
Create a minimal Maven project or use an existing one to run mvn package. This validates the toolchain end-to-end and helps catch environmental issues.
Tip: Use mvn -X package for a verbose log if the build fails. - 8
Tweak for proxy or corporate networks
If you’re behind a proxy, configure settings.xml with proxy details and ensure Maven can reach the central repository.
Tip: Copy settings.xml from the Maven installation and modify the proxy section as needed.
Got Questions?
Do I need Java installed before Maven on Windows?
Yes. Maven relies on Java, so install a supported JDK and ensure JAVA_HOME is set before configuring Maven. Without Java, mvn commands will fail to run.
Yes, you need Java installed first. Maven requires Java, so set JAVA_HOME and ensure java is on your PATH before using Maven.
How do I set JAVA_HOME on Windows?
Open System Properties > Advanced > Environment Variables, create a new system variable named JAVA_HOME, and point it to your JDK installation folder. Then update PATH to include %JAVA_HOME%\bin.
Go to system environment variables, add JAVA_HOME pointing to your JDK, and include %JAVA_HOME%\bin in PATH.
How can I verify Maven is installed correctly?
Open a new terminal and run mvn -version. If Maven, Java, and OS details appear, the installation is successful. If not, re-check JAVA_HOME and PATH settings.
Run mvn -version in a new terminal to confirm Maven and Java are detected.
What if mvn is not recognized after installation?
This usually means PATH hasn’t picked up the Maven bin directory or JAVA_HOME is incorrect. Reopen the terminal after updating PATH, and verify the exact path you added.
If mvn isn’t found, double-check PATH and JAVA_HOME, then reopen the terminal to apply changes.
Should I use the Maven Wrapper (mvnw) on Windows?
Maven Wrapper helps pin a project to a specific Maven version. It’s optional but recommended for team consistency. You can commit the wrapper script with the project.
The Maven Wrapper is optional but handy for consistent builds across teams.
Where can I find authoritative Maven and Java installation guides?
Refer to the official Maven installation guide and the Java SE documentation for authoritative instructions and best practices. Always use trusted sources for downloads.
Check the official Maven and Oracle/OpenJDK docs for guidance and updates.
Watch Video
Main Points
- Install Maven in Windows using a standard binary distribution
- Configure JAVA_HOME and PATH carefully to avoid mvn not found errors
- Verify with mvn -version and perform a sample build
- Use a consistent directory layout for easy maintenance
