Apache Maven – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Sun, 11 Dec 2022 05:06:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Install Maven on macOS (2 Methods) https://tecadmin.net/how-to-install-maven-on-macos/ https://tecadmin.net/how-to-install-maven-on-macos/#respond Thu, 15 Sep 2022 01:13:05 +0000 https://tecadmin.net/?p=31556 Apache Maven is an open-source, community-driven project that aims to build and maintain the most popular Open Source tools for building Java applications. It was created by the Apache Software Foundation in 2001 as an attempt to standardize the build process for Java projects. Over the years, it has developed into a robust set of [...]

The post How to Install Maven on macOS (2 Methods) appeared first on TecAdmin.

]]>
Apache Maven is an open-source, community-driven project that aims to build and maintain the most popular Open Source tools for building Java applications. It was created by the Apache Software Foundation in 2001 as an attempt to standardize the build process for Java projects. Over the years, it has developed into a robust set of tools that can be used for a wide range of projects.

Maven provides a number of benefits, including integration with other tools such as Jenkins, AWS CodeStar, and more. This allows for more automated builds and faster release cycles.

In this tutorial, we will discuss two methods of installing Maven on the macOS system.

  • Method 1: Installing maven using homebrew
  • Method 2: Installing maven manually

Prerequisites

  • Java Development Kit (JDK): Maven 3.3+ require JDK 1.7 or above to execute.
  • Disk: Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository.
  • Operating System: No minimum requirement. Can be run on any operating system with JDK installed.

Method 1: Installing Maven on macOS using Homebrew

The latest Maven is available as Homebrew formulae. Use the following steps to install Maven on macOS along with a few other useful information.

  1. Make sure that the macOS system has Homebrew installed and up to date. The below command will show you the brew version.
    brew --version 
    

    If it is not installed, use next tutorial to install Homebrew on macOS.

  2. Next is to install Maven on macOS. Run the below command to install the available version of Apache Maven on your macOS PC.
    brew install maven 
    
  3. After the installation is finished successfully, You can find the installed Maven version using the below command:
    maven --version 
    
    How to Install Maven on macOS
    Check Maven Version
  4. The Maven’s main configuration file is settings.xml. Homebrew places the this configuration file under the /usr/local/opt/maven/libexec/conf directory. You can see the file with the below command:
    ls -la /usr/local/opt/maven/libexec/conf
    
    total 32
    drwxr-xr-x  5 admin  admin    160 Jun  6 09:16 .
    drwxr-xr-x  6 admin  admin    192 Jun  6 09:16 ..
    drwxr-xr-x  3 admin  admin     96 Jun  6 09:16 logging
    -rw-r--r--  1 admin  admin  10742 Jun  6 09:16 settings.xml
    -rw-r--r--  1 admin  admin   3747 Jun  6 09:16 toolchains.xml
    

That’s it. You have successfully installed Apache Maven on your macOS system.

The below instructions will be useful to upgrade Maven or uninstall it from your system in the future.

  • Upgrade Maven: Skip steps from here, if you have installed Maven right now. The below instructions will be helpful later to upgrade the Maven version. You can upgrade the Maven version anytime with this single command.
    brew upgrade maven 
    
  • Delete Maven: If the Maven is no longer required, uninstall it with the following command.
    brew uninstall maven 
    
  • Method 2: Manually Install Maven on MacOS

    We recommend using Homebrew to install Maven, which also provides the latest packages with easier upgrade options. But if want Maven to install for a specific user, then use the below instructions to install Maven manually on macOS>

    1. You can download the latest Apache Maven from its official download page.

      How to Install Maven on macOS
      Download latest Maven binary files
    2. The downloaded file will be created under the ~/Downloads directory. Open a terminal and extract the downloaded archive file.
      tar xzf ~/Downloads/apache-maven-3.8.6-bin.tar.gz -C ~ 
      
    3. The above command will extract the file under the home directory. You can check the files with the below command:
      ls -la ~/apache-maven-3.8.6/ 
      
      total 64
      drwxr-xr-x   9 admin  staff    288 Sep 14 00:28 .
      drwxr-xr-x+ 20 admin  staff    640 Sep 14 00:28 ..
      -rw-r--r--@  1 admin  staff  17568 Jun  6 09:16 LICENSE
      -rw-r--r--@  1 admin  staff   5141 Jun  6 09:16 NOTICE
      -rw-r--r--@  1 admin  staff   2612 Jun  6 09:16 README.txt
      drwxr-xr-x   8 admin  staff    256 Sep 14 00:28 bin
      drwxr-xr-x@  4 admin  staff    128 Jun  6 09:16 boot
      drwxr-xr-x@  5 admin  staff    160 Jun  6 09:16 conf
      drwxr-xr-x@ 61 admin  staff   1952 Jun  6 09:16 lib
      
    4. macOS 10.5 Catalina or later uses the Zsh as the default shell. You can set the MVN_HOME and edit the PATH environment variable in ~/.zshrc. Edit the ~/.zshrc file and update the following content.
      ~/.zshrc
      export MVN_HOME=~/apache-maven-3.8.6 export PATH=$MVN_HOME/bin:$PATH

      The older macOS users edit the ~/.bash_profile and append the following content.

      ~/.bash_profile
      export MVN_HOME=~/apache-maven-3.8.6 export PATH=$MVN_HOME/bin:$PATH

      To confirm which shell (Zsh or Bash) is active on your system, run the following command.

      echo $SHELL 
      
      /bin/zsh 
      
    5. You can simply restart your shell to apply changes or Use the below command to load the environment variables in the current shell.
      source ~/.zshrc 
      

      Older macOS users change the above command to source ~/.bash_profile file.

    6. That’s it. You have successfully installed Maven on your macOS system. Use the below command to check the installed Maven version:
      mvn --version 
      
      Output:
      Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/admin/apache-maven-3.8.6 Java version: 18.0.2.1, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk/18.0.2.1/libexec/openjdk.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "12.5", arch: "x86_64", family: "mac"

    Conclusion

    Maven relies on defined dependencies between projects to keep everything consistent. This means that changes in one project won’t affect another unless explicitly stated. Maven can integrate with other tools such as Jenkins, AWS CodeStar, and more. This allows for more automated builds and faster release cycles. Maven centralizes all build information into one location, which makes it easy to track issues across teams.

    The above instruction provides you details of Maven installation using Homebrew as well as installing Maven manually by downloading the binary source code.

    The post How to Install Maven on macOS (2 Methods) appeared first on TecAdmin.

    ]]> https://tecadmin.net/how-to-install-maven-on-macos/feed/ 0 How to Install Apache Maven on Ubuntu 22.04 https://tecadmin.net/how-to-install-apache-maven-on-ubuntu-22-04/ https://tecadmin.net/how-to-install-apache-maven-on-ubuntu-22-04/#comments Fri, 27 May 2022 02:33:56 +0000 https://tecadmin.net/?p=29586 Apache Maven is a powerful build and project management tool for Java projects. It is an open-source tool developed by the Apache Software Foundation and is used for managing projects written in Java and other languages. It is a popular tool for managing software builds, as it allows for quick and easy deployment of projects. [...]

    The post How to Install Apache Maven on Ubuntu 22.04 appeared first on TecAdmin.

    ]]>
    Apache Maven is a powerful build and project management tool for Java projects. It is an open-source tool developed by the Apache Software Foundation and is used for managing projects written in Java and other languages. It is a popular tool for managing software builds, as it allows for quick and easy deployment of projects. It also provides a wide range of features including dependency management, project structure, and configuration.

    One of the key advantages of using Apache Maven is that it allows for the easy integration of external libraries into a project. This makes it easier to create complex projects that require multiple external libraries. Another advantage of using Apache Maven is that it allows for the creation of custom-built scripts that can be used to automate the building process. It also makes it easier to maintain the integrity of a project as it allows developers to easily add new dependencies and update existing ones.

    This guide will take you through the step-by-step process of installing Apache Maven on Ubuntu 22.04. Let’s get started!

    Installing Java

    Apache Maven can be configured on any system that has Java installed. The latest Maven version required JDK 1.7 or newer versions. On Ubuntu, you can run the following command to install JDK 11:

    sudo apt update 
    sudo apt install default-jdk 
    

    Once the Java is installed, check the current default set Java version:

    java -version 
    
    Output:
    openjdk 11.0.7 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

    Method 1: Installing Maven Using Apt

    We can quickly install the Apache Maven using the Apt package manager. Open a terminal and execute the following command:

    sudo apt install maven 
    
    Installing Maven on Ubuntu
    Installing Maven on Ubuntu

    You will notice that the old version of Apache Maven was installed from the Apt repository. The second method will help you to install the latest Maven version on the Ubuntu system.

    Method 2: Installing Latest Maven From Source Code

    Follow the below instructions to install the latest Maven version on Ubuntu systems:

    1. You can download Apache maven from its official website or use following command to download Apache Maven 3.8.6 on your system.
      wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz 
      
    2. Now extract the downloaded Maven archive file using the following command.
      sudo tar xzf apache-maven-3.8.6-bin.tar.gz -C /opt 
      sudo ln -s /opt/apache-maven-3.8.6 /opt/maven 
      

      The above commands will extract Maven under the /opt directory and create a symbolic link /opt/maven to that directory.

    3. As you have downloaded pre-compiled Apache Maven files on your system. Now set the environment variables by creating a new file /etc/profile.d/maven.sh.
      sudo vi /etc/profile.d/maven.sh 
      

      Add the below content to the file:

      export JAVA_HOME=/usr/lib/jvm/default-java
      export M2_HOME=/opt/maven
      export MAVEN_HOME=/opt/maven
      export PATH=${M2_HOME}/bin:${PATH}

      Save your file and close it.

    4. Next load the environment variables in the current shell using the following command.
      source /etc/profile.d/maven.sh 
      

      During the next system reboot, the environment will automatically load.

    5. You have successfully installed and configured Apache Maven on your Ubuntu system. You can check the installed Maven version with the following command:
      mvn -version 
      
      Installing Maven on Ubuntu
      Check Maven Version
    6. Finally, clean up the disk by removing the downloaded archive file.
      rm -f apache-maven-3.8.6-bin.tar.gz 
      

    Uninstall (Remove) Apache Maven

    If the Apache Maven is no longer required, you can uninstall it from your system.

    Use the following command to uninstall maven using Apt package manager.

    sudo apt remove --purge maven 
    

    If you have installed maven from the source code, use the following commands to remove it.

    sudo unlink /opt/maven 
    sudo rm -rf /opt/apache-maven-3.8.6 
    

    Conclusion

    In this article, we discussed how to install Apache Maven on Ubuntu 22.04. We discussed the advantages of using Apache Maven and the steps involved in installing and configuring it. We also discussed how to set up a Maven project. With these steps, you can now start using Apache Maven on your system.

    Apache Maven is a powerful tool for managing Java projects. It is a popular choice for managing software builds, as it allows for quick and easy deployment of projects. It also provides a wide range of features including dependency management, project structure, and configuration. If you are looking for an easy way to manage your Java projects, then Apache Maven is a perfect choice.

    The post How to Install Apache Maven on Ubuntu 22.04 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/how-to-install-apache-maven-on-ubuntu-22-04/feed/ 2
    How to Install Maven on Debian https://tecadmin.net/install-apache-maven-on-debian/ https://tecadmin.net/install-apache-maven-on-debian/#comments Sun, 18 Mar 2018 07:52:15 +0000 https://tecadmin.net/?p=15645 Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on Debian 11, Debian 10, Debian 9, and Debian 8 systems. You may like: How to Install Gradle on Debian 10 [...]

    The post How to Install Maven on Debian appeared first on TecAdmin.

    ]]>
    Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on Debian 11, Debian 10, Debian 9, and Debian 8 systems.

    You may like:

    Prerequisites

    Login to your Debian system using shell access. For the remote systems connect over SSH connection.

    ssh root@debian
    

    Run the below commands to upgrade the current packages to the latest version.

    sudo apt update 
    sudo apt upgrade
    

    Step 1 – Install Java

    Apache Maven required Java to be installed on your system. I have installed latest Java 11 on my Debian system using this tutorial.

    java -version 
    
    java version "11.0.2" 2019-01-15 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
    

    Step 2 – Installing Maven on Debian

    After the installation of Java. You are ready to install Apache Maven on Debian. Download the Apache maven archive file from its official website or use the following command to download Apache Maven 3.6.3.

    cd /usr/local
    wget https://www-us.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
    

    Extract the downloaded archive using the following command.

    sudo tar xzf apache-maven-3.8.5-bin.tar.gz
    sudo ln -s apache-maven-3.8.5 apache-maven
    

    Step 3 – Configure Maven Environment

    You need to set the M2_HOME and MAVEN_HOME environment variables to work with Maven on Debian. Also, set the bin directory to the PATH environment variable. You can set the environments variables by creating new file /etc/profile.d/apache-maven.sh.

    sudo vi /etc/profile.d/apache-maven.sh
    

    and add the following content.

    export JAVA_HOME=/usr/lib/jvm/java-11-oracle
    export M2_HOME=/usr/local/apache-maven
    export MAVEN_HOME=/usr/local/apache-maven
    export PATH=${M2_HOME}/bin:${PATH}
    

    Now load the environment variables in the current shell using the following command.

    source /etc/profile.d/apache-maven.sh
    

    Step 4 – Verify Installation

    You have successfully installed and configured Apache Maven on your Ubuntu system. Use the following command to check the version of Maven.

    mvn -version
    
    Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
    Maven home: /usr/local/apache-maven
    Java version: 11.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
    Default locale: en, platform encoding: UTF-8
    OS name: "linux", version: "4.15.0-46-generic", arch: "amd64", family: "unix"
    

    The Installation of Apache Maven on the Debian system has been completed successfully. You can now remove the downloaded archive file from your system to free space.

    rm -f apache-maven-3.8.5-bin.tar.gz
    

    To read more about Apache Maven visit here.

    The post How to Install Maven on Debian appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-apache-maven-on-debian/feed/ 2
    How To Install Apache Maven on Ubuntu 18.04 https://tecadmin.net/install-apache-maven-on-ubuntu/ https://tecadmin.net/install-apache-maven-on-ubuntu/#comments Mon, 06 Feb 2017 12:31:34 +0000 https://tecadmin.net/?p=11198 Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on your Ubuntu 19.10 LTS, 18.04 LTS, and 16.04 LTS systems. You may like: How to Install Gradle on Ubuntu 18.04 [...]

    The post How To Install Apache Maven on Ubuntu 18.04 appeared first on TecAdmin.

    ]]>
    Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on your Ubuntu 19.10 LTS, 18.04 LTS, and 16.04 LTS systems.

    You may like:

    Step 1 – Prerequisites

    First of all, you make sure that you installed appropriate Java on your system.Java is the primary requirement of installing Apache Maven on nix systems. So firstly you need to install Java on your system also make sure you have installed JDK and JRE both.

    java -version 
    
    openjdk 11.0.6 2020-01-14
    OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
    OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
    

    If you don’t have Java Development Kit installed on your system. Visit install Java 11 on Ubuntu

    Step 2 – Install Maven on Ubuntu

    After verifying java version on your system. Download Apache maven from its official website or use following command to download Apache Maven 3.6.3.

    cd /usr/local
    wget  wget https://www-us.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
    

    Now extract downloaded archive using following command.

    sudo tar xzf apache-maven-3.8.5-bin.tar.gz
    sudo ln -s apache-maven-3.8.5 apache-maven
    

    Step 3 – Setup Environment Variables

    As you have downloaded pre compiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.

    sudo vi /etc/profile.d/apache-maven.sh
    

    and add following content.

    export JAVA_HOME=/usr/lib/jvm/java-11-oracle
    export M2_HOME=/usr/local/apache-maven
    export MAVEN_HOME=/usr/local/apache-maven
    export PATH=${M2_HOME}/bin:${PATH}
    

    Now load the environment variables in current shell using following command.

    source /etc/profile.d/apache-maven.sh
    

    Step 4 – Verify Installation

    You have successfully installed and configured Apache Maven on your Ubuntu system. Use the following command to check the version of Maven.

    mvn -version
    
    Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
    Maven home: /usr/local/apache-maven
    Java version: 11.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
    Default locale: en, platform encoding: UTF-8
    OS name: "linux", version: "4.18.0-147.3.1.el8_1.x86_64", arch: "amd64", family: "unix"
    

    Finally, remove the downloaded archive file from local.

    rm -f apache-maven-3.6.3-bin.tar.gz
    

    To read more about Apache Maven visit here.

    The post How To Install Apache Maven on Ubuntu 18.04 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-apache-maven-on-ubuntu/feed/ 8
    How To Install Apache Maven on CentOS/RHEL 8/7 https://tecadmin.net/install-apache-maven-on-centos/ https://tecadmin.net/install-apache-maven-on-centos/#comments Mon, 08 Aug 2016 10:35:18 +0000 https://tecadmin.net/?p=10633 Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on your CentOS/RHEL 8/7 and Fedora 31/30/29 systems. You may like: How to Install Gradle on CentOS 8 Step 1 – [...]

    The post How To Install Apache Maven on CentOS/RHEL 8/7 appeared first on TecAdmin.

    ]]>
    Apache Maven is a software project management and comprehension tool. Maven can manage a project’s build, reporting, and documentation from a central piece of information. This tutorial will help you to install Apache Maven on your CentOS/RHEL 8/7 and Fedora 31/30/29 systems.

    You may like:

    Step 1 – Prerequisite

    Java development kit is the primary requirement of Apache Maven. So you need to install the Java development kit (JDK) on your system. Make sure you have installed JDK, not JRE. se following command to install it.

    yum install java-11-openjdk
    

    Verify installed Java version on your system.

    java -version 
    
    openjdk version "11.0.6" 2020-01-14 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.6+10-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10-LTS, mixed mode, sharing)
    

    If you don’t have Java Development Kit installed on your system. Visit Install Java 11 on CentOS/RHEL 7/6 and Fedora

    Step 2 – Install Apache Maven

    After verifying java version on your system. Download Apache Maven from its official website or use the following command to download Apache Maven 3.6.2.

    cd /opt
    wget https://www-us.apache.org/dist/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
    

    Now extract downloaded archive using following command.

    sudo tar xzf apache-maven-3.8.5-bin.tar.gz
    sudo ln -s apache-maven-3.8.5 maven
    

    Step 3 – Setup Environment Variables

    As you have downloaded precompiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.

    sudo vi /etc/profile.d/maven.sh
    

    and add the following content.

    export M2_HOME=/opt/maven
    export PATH=${M2_HOME}/bin:${PATH}
    

    Now load the environment variables in current shell using following command.

    source /etc/profile.d/maven.sh
    

    Step 4 – Check Maven Version

    Apache Maven has been successfully configured on your system. Use the following command to check the version of installed Maven on your system.

    mvn -version
    
    Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
    Maven home: /opt/maven
    Java version: 11.0.6, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk-11.0.6.10-0.el8_1.x86_64
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "4.18.0-147.3.1.el8_1.x86_64", arch: "amd64", family: "unix"
    

    Finally, remove the downloaded archive file from the system to free disk space.

    rm -f apache-maven-3.8.5-bin.tar.gz
    

    The post How To Install Apache Maven on CentOS/RHEL 8/7 appeared first on TecAdmin.

    ]]>
    https://tecadmin.net/install-apache-maven-on-centos/feed/ 41