1.下載jdk(采坑备禀,不要使用openjdk,因?yàn)闆](méi)有jre運(yùn)行環(huán)境,也可使用命令下載曲尸,各有所愛(ài))
jdk下載地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
版本:jdk-8u231-linux-x64.tar.gz
創(chuàng)建目錄
$ mkdir -p /usr/local/java
解壓
$ tar -zxvf jdk-8u231-linux-x64.tar.gz
改名
$ mv jdk-8u231-linux-x64 jdk1.8
編輯環(huán)境
$ vi /etc/profile
在文件末尾添加
#java
JAVA_HOME=/usr/local/java/jdk1.8
JRE_HOME=/usr/local/java/jdk1.8/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
重新加載環(huán)境
$ source /etc/profile
驗(yàn)證是否安裝成功
$ java -version
顯示如下成功
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
2.安裝maven(預(yù)先裝下wget ,命令 yum install wget)
下載地址:https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz
版本:apache-maven-3.6.2-bin
創(chuàng)建目錄
$ mkdir -p /usr/local/test
下載
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin.tar.gz
解壓
$ tar -zxvf binaries/apache-maven-3.6.2-bin.tar.gz
重命名
$ mv apache-maven-3.6.2 maven
移動(dòng)
$mv maven ../
編輯環(huán)境
$ vi /etc/profile
在文件末尾添加
#maven
export MAVEN_HOME=/usr/local/maven
export PATH=${JAVA_HOME}/bin:/usr/local/mysql/bin:${MAVEN_HOME}/bin:$PATH
重新加載環(huán)境
$ source /etc/profile
驗(yàn)證安裝是否成功
$mvn -v
輸出如下
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /usr/local/maven
Java version: 1.8.0_231, vendor: Oracle Corporation
Java home: /usr/local/java/jdk1.8/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.el7.x86_64", arch: "amd64", family: "unix"