1、下载 jdk
这里我们拿jdk8来作为例子
下载地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
2.把下载的文件 jdk-8u151-linux-x64.tar.gz 放在/usr/local/java/目录下并解压
mkdir /usr/local/java
cd /usr/local/java
tar -zxvf jdk-8u151-linux-x64.tar.gz
3.配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
source /etc/profile
java -version
4.下载maven安装包并解压
安装包直接去apache官网下载:https://maven.apache.org/download.cgi
5.把下载的文件 apache-maven-3.6.3-bin.tar.gz 放在/usr/local/目录下并解压
tar -zxvf apache-maven-3.6.3
6.配置环境变量
vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=$MAVEN_HOME/bin:$PATH
source /etc/profile
mvn -v