I just downloaded Apache Maven and extracted it to my C drive, but when I run 'mvn -version' in the terminal, I get the error: "mvn is not recognized as an internal or external command." I have already set my JAVA_HOME variable correctly. Do I need to restart my computer, or am I missing a specific step in the Environment Variables setup to make the Maven command accessible globally?
3 answers
To resolve this, you need to add the Maven bin folder to your System PATH. First, ensure you have a variable named MAVEN_HOME (or M2_HOME) pointing to your main Maven folder, such as C:\apache-maven-3.9.6. Then, find the "Path" variable in your System Environment Variables and add a new entry: %MAVEN_HOME%\bin. Once you save these changes, it is vital that you close any existing Command Prompt or PowerShell windows and open a fresh one. The terminal only loads environment variables when it first starts, so an old window will never recognize the new path. This is the standard procedure for setting up CLI tools in Windows-based Software Development environments.
If I am using an IDE like IntelliJ IDEA or Eclipse, do I still need to configure the system environment variables, or can the IDE handle the Maven execution internally?
Make sure there are no spaces in your Maven installation path. Sometimes Windows has trouble parsing paths like "C:\Program Files\Maven" if they aren't wrapped in quotes inside the PATH variable.
I agree with Nancy! I spent two hours debugging this once just to realize a space in the folder name was breaking the link. Kimberly, if you've followed Barbara's steps and it still fails, try moving the Maven folder to C:\Maven and updating your variables. It’s a much "cleaner" setup for development tools.
Steven, most modern IDEs actually come with a "bundled" version of Maven, so they can run builds internally without the system PATH being set. However, if you plan to run any commands from the built-in terminal or use external automation scripts, you will still hit that "not recognized" error. For a professional Software Development workflow, it is always best to have Maven configured at the OS level so your command line behavior matches your IDE's behavior exactly.