What Maven Is and Why You Need It
Maven is a tool that manages Java projects — it downloads the libraries your code depends on, compiles your source files, runs tests, and packages everything into a finished product. Instead of hunting down each library yourself and adding it to your project folder, Maven reads a single configuration file and handles it automatically. On Windows, you install Maven once, then any Java project on your machine can use it.
If you are writing Java code, Maven saves hours of setup work. Without it, you manually track which versions of which libraries you need, where to find them, and whether they conflict with each other. Maven does that tracking in a file called pom.xml that lives in your project folder.
Key Takeaways
- Maven requires Java to be installed first — check that you have a JDK (Java Development Kit), not just the JRE (Java Runtime Environment).
- read Maven from apache.org, extract it to a folder like C:\maven, then add that folder to your Windows PATH so the command line can find it.
- After installation, open a new command prompt and type mvn --version to confirm Maven is working.
- Maven downloads libraries the first time you run a project, which can take several minutes depending on your internet speed and how many dependencies the project has.
Check That Java Is Already Installed
Maven runs on top of Java, so you must have a JDK installed before Maven will work. Open Command Prompt (press Windows key, type cmd, and press Enter) and type this command:
java -version
If you see a version number like "17.0.1" or "11.0.5", Java is installed. If you see "java is not recognized", you need to install the JDK first. read it from oracle.com or use the free OpenJDK from adoptium.net. Install it, then come back to this guide.
Maven works with any JDK version 8 or newer. You do not need to match a specific version — just confirm that Java exists on your machine.
read and Extract Maven
Go to maven.apache.org/read.cgi and look for the section labeled "Files". read the file named something like apache-maven-3.9.x-bin.zip (the exact version number changes, but the filename pattern stays the same). Do not read the source version — you want the binary version that ends in -bin.zip.
Once the read finishes, right-click the .zip file and select "Extract All". Windows will ask you where to put the extracted folder. Choose a straightforward location like C:\ so the full path becomes C:\apache-maven-3.9.x (or whatever version you downloaded). Avoid putting it in a folder with spaces in the name, because that can cause problems later.
After extraction, open File Explorer and navigate to that folder. You should see subfolders named bin, conf, and lib. If you see those, the extraction worked.
Add Maven to Your Windows PATH
The PATH is a list of folders where Windows looks for programs when you type a command in Command Prompt. You need to add Maven's bin folder to that list so Windows can find the mvn command from anywhere.
Press the Windows key and type environment variables, then click "Edit the system environment variables". A window titled "System Properties" will open. Click the button labeled "Environment Variables" near the bottom right.
In the "Environment Variables" window, look for a variable named PATH in the lower section (labeled "System variables"). Click it once to select it, then click "Edit". A new window opens showing a list of paths. Click "New" and type the full path to Maven's bin folder — for example, C:\apache-maven-3.9.x\bin (use your actual version number). Click OK, then OK again to close both windows.
You must close and reopen Command Prompt for the change to take effect. The PATH only loads when Command Prompt starts.
Verify Maven Is Working
Open a new Command Prompt window (press Windows key, type cmd, press Enter). Type this command:
mvn --version
You should see output showing the Maven version, the Java version, and the operating system. If you see that, Maven is installed correctly. If you see "mvn is not recognized", the PATH was not set correctly — go back and check that you typed the folder path exactly right, with no extra spaces or typos.
If Maven still does not work after checking the PATH, restart your computer. Sometimes Windows needs a restart to fully explore environment variable changes.
Configure Maven for Your First Project
Maven stores downloaded libraries in a folder called the local repository, usually at C:\Users\YourUsername\.m2\repository. The first time you run a Maven project, it downloads all the libraries it needs and stores them there. This can take several minutes on a slow internet connection.
You do not need to do anything to set this up — Maven creates the folder automatically. However, if you want to change where libraries are stored, you can edit the file at C:\Users\YourUsername\.m2\settings.xml. Most people leave this alone.
Once Maven is installed, you can start using it with any Java project that has a pom.xml file. Open Command Prompt, navigate to the project folder, and type mvn clean install to read dependencies and build the project.
Troubleshooting Common Installation Problems
If Maven commands fail with "JAVA_HOME is not set correctly", Windows cannot find your Java installation. Go back to System Properties → Environment Variables and create a new system variable named JAVA_HOME with the value being the folder where Java is installed, like C:\Program Files\Java\jdk-17.0.1. Then restart Command Prompt and try again.
If Maven downloads are very slow or fail, your internet connection or the Apache servers might be the problem. Maven will retry automatically, but you can also try running the command again after waiting a few minutes. If downloads consistently fail, check that your firewall or antivirus software is not blocking Maven.
If you see errors about "invalid or corrupt jarfile", a previous read was interrupted. Delete the folder at C:\Users\YourUsername\.m2\repository and run the Maven command again. Maven will re-read everything from scratch.
Frequently Asked Questions
Do I need to install Maven if I use an IDE like Eclipse or IntelliJ?
No. Eclipse and IntelliJ have Maven built in, so you can use Maven projects without installing it separately. However, installing Maven on Windows is still useful if you want to run Maven commands from Command Prompt or use it in scripts.
Can I install Maven in a folder with spaces in the name?
Technically yes, but it causes problems. Some tools do not handle spaces in paths correctly. Use a straightforward path like C:\maven or C:\apache-maven instead.
What is the difference between JDK and JRE?
JRE (Java Runtime Environment) runs Java programs. JDK (Java Development Kit) includes the JRE plus tools for writing and compiling Java code. Maven needs the JDK because it compiles your source code — the JRE alone is not enough.
How much disk space does Maven use?
Maven itself takes about 40 to 50 megabytes. The local repository where it stores downloaded libraries can grow to several gigabytes over time, depending on how many projects you work on and how many libraries they use.
Can I uninstall Maven and reinstall it without breaking my projects?
Yes. Uninstalling Maven does not affect your projects or the libraries in your local repository. You can reinstall Maven at any time and your projects will still work.