Maven is a build and dependency management tool. Instead of manually downloading JAR files for Selenium, TestNG, and every library — you list them in a pom.xml file and Maven downloads them automatically. Every professional automation project uses Maven (or Gradle).
mvn compilemvn testGo to: https://maven.apache.org/download.cgi
Under "Files" → download the Binary zip archive (the file named apache-maven-3.9.x-bin.zip). Do NOT download the "Source" version — that is Maven's own source code, not the tool itself.
apache-maven-3.9.x-bin.zip from https://maven.apache.org/download.cgiC:\Program Files\Apache\maven\apache-maven-3.9.9\binmvn -versionApache Maven 3.9.9
Maven home: C:\Program Files\Apache\maven\apache-maven-3.9.9
Java version: 17.0.x, vendor: Eclipse Adoptium
Default locale: en_US, platform encoding: UTF-8# Easiest way — using Homebrew:
brew install maven
# Verify:
mvn -versionIf you do not have Homebrew, manual install:
/opt/maven or any permanent folder: sudo mkdir -p /opt/maven && sudo tar -xzf apache-maven-3.9.x-bin.tar.gz -C /opt/maven --strip-components=1# Add these lines to ~/.zshrc:
echo 'export MAVEN_HOME=/opt/maven' >> ~/.zshrc
echo 'export PATH=$MAVEN_HOME/bin:$PATH' >> ~/.zshrc
# Reload:
source ~/.zshrc
# Verify:
mvn -version| Error | Cause | Fix |
|---|---|---|
| "mvn" is not recognized | Maven bin folder not in PATH | Add %MAVEN_HOME%\bin to your PATH environment variable |
| JAVA_HOME is not set | Maven cannot find JDK | Set JAVA_HOME to your JDK installation path (see Lesson 1) |
| mvn shows wrong Java version | JAVA_HOME points to wrong JDK | Update JAVA_HOME to point to JDK 17 |
| Download fails / connection timeout | Firewall or proxy blocking | Try downloading from a different network, or configure Maven proxy in settings.xml |
At this point, all three tools should work. Run these commands:
java -version # Should show JDK 17
javac -version # Should show JDK 17
mvn -version # Should show Maven 3.9.x with Java 17If all three commands work, your development environment is ready. Next, you will create your first project.
Exercise 1: Run mvn -version and confirm it shows Java 17 in the output. If it shows a different Java version, your JAVA_HOME is pointing to the wrong JDK.
Exercise 2: Navigate to any empty folder and run mvn --help. Read the first few lines — you will see the available commands (compile, test, package, install). You will use these later.