Logo
Environment Setup
Environment SetupInstalling Maven/Gradle

Installing Maven/Gradle

Maven and Gradle are the two most popular build automation tools in the Java ecosystem. They manage dependencies and facilitate various build-related tasks. Here's how to install Maven and Gradle on different operating systems.

Installing Maven

Windows
  1. Download Maven: Visit the official Maven website and download the binary zip archive.

  2. Extract Zip: Extract the downloaded zip file to a directory of your choice, such as C:\Program Files\Apache\Maven.

  3. Set Environment Variables:

    • Add a new system variable named M2_HOME with the value as the path to your Maven directory.
    • Update the PATH system variable to include %M2_HOME%\bin.
macOS/Linux
  1. Download Maven: You can download Maven from the official website or install it via package managers.

    brew install maven  # macOS
    sudo apt install maven  # Ubuntu
  2. Set Environment Variables: Open your .bashrc or .zshrc file and add the following lines.

    export M2_HOME=/path/to/maven
    export PATH=$PATH:$M2_HOME/bin

Installing Gradle

Windows
  1. Download Gradle: Visit the official Gradle website and download the binary zip archive.

  2. Extract Zip: Extract the downloaded zip file to a directory of your choice, such as C:\Program Files\Gradle.

  3. Set Environment Variables:

    • Add a new system variable named GRADLE_HOME with the value as the path to your Gradle directory.
    • Update the PATH system variable to include %GRADLE_HOME%\bin.
macOS/Linux
  1. Download Gradle: You can download Gradle from the official website or install it via package managers.

    brew install gradle  # macOS
    sudo apt install gradle  # Ubuntu
  2. Set Environment Variables: Open your .bashrc or .zshrc file and add the following lines.

    export GRADLE_HOME=/path/to/gradle
    export PATH=$PATH:$GRADLE_HOME/bin

After installation, open a new terminal window and run mvn -v for Maven or gradle -v for Gradle to verify that the tool has been successfully installed.

Book a conversation with us for personalize training today!

Was this helpful?
Logo