Home > Java > javaTutorial > CentOS7 Maven installation tutorial step by step

CentOS7 Maven installation tutorial step by step

WBOY
Release: 2024-02-18 10:07:24
Original
1002 people have browsed it

CentOS7 Maven installation tutorial step by step

CentOS7, as a widely used Linux operating system, provides developers with a stable and reliable platform. When developing Java projects, Maven is a very important build tool. It can help developers automatically build projects, manage dependencies, etc. This article will introduce in detail how to install Maven from scratch on CentOS7 and provide specific code examples.

Step One: Install Java

Before installing Maven, you first need to ensure that Java is installed on the system. On CentOS7, you can use the following command to install Java (assuming you are using OpenJDK):

sudo yum install java-1.8.0-openjdk
Copy after login

After the installation is complete, you can use the following command to verify whether Java is successfully installed:

java -version
Copy after login

If Java is successfully displayed version information, the installation is successful.

Step 2: Download Maven

Next, you need to download the Maven compressed package. You can download Maven through the official website, or use the wget command to download. Assume that we downloaded Apache Maven 3.6.3 version:

wget https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
Copy after login

After the download is complete, you can use the following command to decompress Maven:

tar -zxvf apache-maven-3.6.3-bin.tar.gz
Copy after login

Step 3: Configure environment variables

Next, you need to configure Maven's environment variables so that the system can recognize and use Maven. Edit the /etc/profile file and add the following content:

export MAVEN_HOME=/path/to/apache-maven-3.6.3
export PATH=$PATH:$MAVEN_HOME/bin
Copy after login

After saving the file, execute the following command to make the environment variables take effect:

source /etc/profile
Copy after login

Step 4: Verify the installation

Finally, use the following command to verify whether Maven is successfully installed:

mvn -version
Copy after login

If the Maven version information is successfully displayed, the installation is successful.

At this point, we have completed the process of installing Maven from scratch on CentOS7. Through the above steps, you can smoothly integrate Maven into your development environment and exert its powerful functions in Java project development.

I hope this article can be helpful to you, and I wish you success in completing the installation and configuration of Maven!

The above is the detailed content of CentOS7 Maven installation tutorial step by step. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template