CentOS7 下rpm安装jdk8
1、查看并卸载自带的openjdk
1)查看系统中默认安装的JDK
rpm -qa|grep jdk
2)卸载JDK相关文件:
yum -y remove *openjdk*
2、下载JDK8安装包
1)官网
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
3、安装JDK - rpm方式(你具体的包名):
rpm -ivh jdk-8u*-linux -x64.rpm
4、配置环境变量
1) 编辑profile文件进行配置环境变量
vim /etc/profile
2) 输入i后在末尾添加以下内容:
# set jdk
export JAVA_HOME=/usr/java/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5、重启加载profile让系统文件生效
source /etc/profile
6、验证是否安装成功
java -version
//输出的内容
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
原文:https://www.cnblogs.com/leeboke/p/15239636.html