Monday, 20 July 2015

Apache Maven : Apache Maven Installation (Windows OS)

🚀 Want to Master Java Build Tools & Project Automation?

Subscribe to Ram N Java for beginner-friendly coding tutorials, server configurations, and practical build guides!

🔔 Subscribe to YouTube Channel

Maven Installation on Windows Operating System: The Easy Step-by-Step Guide

Apache Maven is the industry standard build automation and dependency management tool for Java applications. From downloading required libraries automatically via central repositories to running automated tests and packaging JAR or WAR files, Maven simplifies the complete project lifecycle. Setting it up on Windows takes only a few minutes when following the proper configuration steps.

1. Prerequisites Before Installing Maven

Before configuring Maven, ensure your system meets the basic requirements:

  • Java Development Kit (JDK): Maven requires JDK to compile Java source code. Make sure JDK (Java 8 or higher) is installed.
  • JAVA_HOME Environment Variable: Ensure your JAVA_HOME system environment variable points directly to your JDK directory (e.g., C:\Program Files\Java\jdk-17).
  • Verify Java: Open Command Prompt and run java -version and echo %JAVA_HOME% to confirm Java is ready.

2. Downloading and Extracting Apache Maven

Maven does not require a traditional installer; it runs directly from its binary directory:

  • Visit the official Apache Maven website: https://maven.apache.org/download.cgi.
  • Under the Files section, download the Binary zip archive (e.g., apache-maven-x.x.x-bin.zip).
  • Extract the downloaded zip archive to a clean, permanent directory such as C:\apache-maven or C:\Program Files\apache-maven.

3. Setting Up MAVEN_HOME and PATH Environment Variables

To allow the Windows Command Prompt to recognize Maven commands from any directory:

  • Press Win + S, search for Environment Variables, and open Edit the system environment variables.
  • Click the Environment Variables... button at the bottom right.
  • Under System variables, click New:
    • Variable name: MAVEN_HOME (or M2_HOME)
    • Variable value: Path to your extracted Maven folder (e.g., C:\apache-maven-3.9.x)
  • Under System variables, locate the Path variable and click Edit.
  • Click New and add: %MAVEN_HOME%\bin (or the direct path like C:\apache-maven-3.9.x\bin).
  • Click OK on all dialog boxes to save the configuration.

4. Verifying the Maven Installation

Test that the command-line interface communicates with Maven:

  • Open a fresh Command Prompt window (to reload system environment variables).
  • Run the command: mvn -version (or mvn -v).
  • You should see details showing the Apache Maven version, Maven home directory, Java version, and OS details. If displayed, Maven is fully configured and ready to use!

Click here to watch on YouTube:
https://www.youtube.com/watch?v=1HIURDQIoU4&list=UUhwKlOVR041tngjerWxVccw

Click here to download Apache Maven:
https://maven.apache.org/download.cgi

No comments:

Post a Comment

Tutorials