Thursday, June 20, 2024

Maven Installation and Setup Guide

Maven Installation and Setup Guide

Pre-Requisites

  • Java (JDK) must be installed

Download Maven

  1. Go to the Maven Download Page:
  2. Download Binary Zip Archive:
    • Click on apache-maven-3.9.7-bin.zip to download the zip file.
    • Extract the zip file by right-clicking on apache-maven-3.9.7-bin.zip and selecting Extract to apache-maven-3.9.7-bin.zip.
    • This will create a new folder named apache-maven-3.9.7-bin.

Set Environment Variables

  1. Set JAVA_HOME:

    • Variable name: JAVA_HOME
    • Variable value: C:\Program Files\Java\jdk-11.0.15.1 (Adjust this path to where JDK is installed on your system)
  2. Set MAVEN_HOME:

    • Variable name: MAVEN_HOME
    • Variable value: C:\brahma\seleniumSoftwares\apache-maven-3.9.7-bin
  3. Add to PATH Environment Variable:

    • Add the following to the PATH variable:

      %JAVA_HOME%\bin %MAVEN_HOME%\bin

Steps to Add Environment Variables

  1. Press the Windows button on your keyboard and type environment variables.

  2. Select Edit the system environment variables.

  3. In the System Properties window, click the Environment Variables button.

  4. In the Environment Variables window, click the New button under the System variables section.

    To add JAVA_HOME:

    • Enter JAVA_HOME as the variable name.
    • Enter C:\Program Files\Java\jdk-11.0.15.1 as the variable value (Adjust as necessary).
    • Click OK.

    To add MAVEN_HOME:

    • Enter MAVEN_HOME as the variable name.
    • Enter C:\brahma\seleniumSoftwares\apache-maven-3.9.7-bin as the variable value.
    • Click OK.
  5. To update the Path variable:

    • Find and select the Path variable in the System variables section, then click Edit.
    • Click New and add %JAVA_HOME%\bin.
    • Click New again and add %MAVEN_HOME%\bin.
    • Click OK.

Verify Maven Installation

  1. Open the Run dialog by pressing Win + R, type cmd, and press Enter to open the Command Prompt.

  2. Check Java version:

    java -version

    Example output:


    java version "11.0.15.1" 2022-04-22 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.15.1+2-LTS-10) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.15.1+2-LTS-10, mixed mode)
  3. Check Maven version:


    mvn -version

    Example output:


    Apache Maven 3.9.7 (xxxxx) Maven home: C:\brahma\seleniumSoftwares\apache-maven-3.9.7-bin Java version: 11.0.15.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.15.1 Default locale: en_IN, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  4. Verify environment variables:

    • To check JAVA_HOME:


      echo %JAVA_HOME%

      Expected output:


      C:\Program Files\Java\jdk-11.0.15.1
    • To check MAVEN_HOME:


      echo %MAVEN_HOME%

      Expected output:


      C:\brahma\seleniumSoftwares\apache-maven-3.9.7-bin

Add Maven Plugin in Eclipse

  1. Open Eclipse.
  2. Go to Help > Eclipse Marketplace.
  3. In the Eclipse Marketplace window, type maven in the search box and press Enter.
  4. Select the Maven m2e plugin and click the Install button.
  5. Follow the prompts to complete the installation.

Verify Maven Plugin in Eclipse

  1. Go to Help > Eclipse Marketplace.
  2. Check the Installed tab for Maven integration and other plugins like TestNG, Git, Cucumber.

Summary

  1. Download JDK and Maven.

  2. Set environment variables:

    • JAVA_HOME
    • MAVEN_HOME
    • Update Path to include %JAVA_HOME%\bin and %MAVEN_HOME%\bin.
  3. Verify installations:

    • Check Java version with java -version.
    • Check Maven version with mvn -version.
    • Verify JAVA_HOME and MAVEN_HOME paths.
  4. Install Maven plugin in Eclipse.

For more detailed steps and troubleshooting, refer to Mkyong's Maven installation guide.

No comments:

Post a Comment

git commands MCQ

 Here are some multiple-choice questions (MCQs) on Git commands relevant for Selenium: 1. Which Git command is used to clone a remote reposi...