Apache Maven is a powerful project management tool that is based on POM (project object model). maven is a tool that can be used for building and managing any Java-based project. Maven contains XML files also referred to as pom.xml which include configuration details, project dependencies, and other data.
This article will show two different ways to install Apache Maven on OpenSuse 15.1 and other versions of OpenSuse.
I. Install Maven on OpenSuse 15.1
- Installation of Java: Updating the package index:
sudo zypper up
- Install the OpenJDK package:
sudo zypper install java-11-openjdk-devel
- Verifying the java installation:
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-suse-lp220.127.116.11-x8664)
OpenJDK 64-Bit Server VM (build 11.0.13+8-suse-lp18.104.22.168-x8664, mixed mode)
Apache Maven Download
- Download the stable version of Apache maven and you can download it to the /tmp directory, as shown below:
sudo wget http://mirrors.advancedhosters.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
- The file will be downloaded as a tar.gz file. You can extract files to /opt directory:
sudo tar -xvzf apache-maven-3.6.3-bin.tar.gz -C /opt
- In order to have control of Maven versions and updates, we will create a symbolic link to Maven that points to the Maven installation directory. Run the below command:
sudo ln -s /opt/apache-maven-3.6.3 /opt/maven
- Move to the root path before setting up the environments for maven:
Setup the Environment for Maven
You must configure a few environment variables, including JAVA_HOME, M3_HOME, and MAVEN_HOME.
- Create a new file named
sudo vi /etc/profile.d/maven.sh
- The configuration below needs to be added to this newly created file:
Save and close the file.
- Provide the required privileges to the file using the command below:
sudo chmod +x /etc/profile.d/maven.sh
- Load the environment variables using the
Verify the maven installation
- Use the
mvn -versioncommand which will print the Maven version:
Apache Maven 3.6.3 (SUSE 3.6.3-lp152.2.31)
Maven home: /usr/share/maven
Java version: 11.0.13, vendor: Oracle Corporation, runtime: /usr/lib64/jvm/java-11-openjdk-11
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "5.3.18-lp152.17-default", arch: "amd64", family: "unix"
Install Apache Maven using zypper
- Easy and simple way to install maven using zipper. Update the package index by using the following command,
sudo zypper up
- Install Maven.
sudo zypper install maven
- Verify the installation by running the