How to Install Apache Maven on Ubuntu 22.04 Terminal?
Hello everyone,
In this article, I'll provide you with a step-by-step guide on how to install Apache Maven on Ubuntu 22.04. We'll walk through the process of installing Apache Maven on this version of Ubuntu, helping you become familiar with the installation procedure. I'm excited to show you how to set up Apache Maven on your Ubuntu 22.04 system.
To install Apache Maven on Ubuntu 22.04, you can follow these step-by-step instructions:
Step 1: Update Package List
Open a terminal window by pressing `Ctrl+Alt+T`, and then update the package list to make sure you have the latest information about available packages:
sudo apt update
Step 2: Install Apache Maven
You can install Apache Maven directly from the Ubuntu repositories using the `apt` package manager. Run the following command to install Maven:
sudo apt install maven
This command will download and install Apache Maven and its dependencies.
Step 3: Verify the Installation
Once the installation is complete, you can verify that Maven was installed successfully by checking its version:
mvn -version
You should see Maven's version information displayed in the terminal, which confirms that it was installed successfully.
Step 4: Configure Environment Variables (Optional)
By default, Maven should work without any additional configuration. However, if you want to set environment variables for Maven, you can do so. Open the `.bashrc` file for editing:
nano ~/.bashrc
Add the following lines at the end of the file to set the environment variables for Maven:
export M2_HOME=/usr/share/maven
export M2=/usr/share/maven/bin
export PATH=$PATH:/usr/share/maven/bin
Save and exit the text editor by pressing `Ctrl+X`, followed by `Y` to confirm the changes and then `Enter`.
To apply the changes, reload the `.bashrc` file:
source ~/.bashrc
Step 5: Test Maven
To ensure that the environment variables are set correctly and that Maven is working as expected, open a new terminal window and run the following command:
mvn -version
You should see the same Maven version information as before, indicating that Maven is configured correctly.
That's it! You have successfully installed Apache Maven on Ubuntu 22.04 and can now use it for your Java projects.
I hope it can help you...