1) yum 安装java jdk 1.8
* -y
验证java
[root@localhost local]# java -version openjdk version "1.8.0_222" OpenJDK Runtime Environment (build 1.8.0_222-b10) OpenJDK -Bit Server VM (build 25.222-b10, mixed mode) [root@localhost local]# javac -version javac 1.8.0_222
2) 编译安装 java jdk1.8
a) 官网下载页面是http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
找到合适的源码包,笔者选的是linux 64位 tar.gz格式源码文件包
登录Oracle账号
b) 源码包解压到/usr/local/
cd /usr/local/ wget '刚才复制的下载链接地址' tar zxvf jdk-8u221-*
解压后的文件名是jdk1.8.0_221, 可以做一个软连接
.0_221/ jdk1.
c) 配置java环境变量/etc/profile
echo 'export JAVA_HOME=/usr/local/jdk1.8/' >> /etc/profile echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile echo 'export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH' >> /etc/profile source /etc/profile
d) 验证一下Java环境是否正常,没有报错就是正常
[root@localhost ~]# java -version openjdk version "1.8.0_221" OpenJDK Runtime Environment (build 1.8.0_221-b04) OpenJDK -Bit Server VM (build 25.221-b04, mixed mode) [root@localhost ~]# javac -version javac 1.8.0_221