查看可安装的jdk版本
yum search java|grep jdk
安装指定jdk版本
yum install java-1.8.0-openjdk
查看安装目录
which java
这个时候javac命令是不能执行的,需要安装java-1.8.0-openjdk-devel.x86_64
yum install java-1.8.0-openjdk-devel.x86_64
设置环境变量
vi /etc/profile
#set java environment JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
下载maven
wget https://mirrors.aliyun.com/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -xf apache-maven-3.6.3-bin.tar.gz -C /usr/local/
mv /usr/local/apache-maven-3.6.3 /usr/local//maven3
设置环境变量
vi /etc/profile
#set maven environment MAVEN_HOME=/usr/local//maven3
export PATH=${MAVEN_HOME}/bin:${PATH}
export PATH=$PATH:/usr/local/mysql/bin:$MAVEN_HOME/bin
刷新配置文件
source /etc/profile
查看配置是否生效
[root@x3109b local]# mvn -v Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /usr/local/maven Java version: 1.8.0_252, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "3.10.0-1127.el7.x86_64", arch: "amd64", family: "unix" [root@x3109b local]# java -version openjdk version "1.8.0_252" OpenJDK Runtime Environment (build 1.8.0_252-b09) OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)