环境
centos7操作系统
步骤
- 查看安装的jdk
[root@localhost ~]#rpm -qa | grep openjdk
java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64
java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64
java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64 - 卸载jdk
yum -y remove java-* - 下载jdk
wget --no-cookie --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz
解压: tar -zxvf jdk-8u171-linux-x64.tar.gz
重命名: mv jdk-8u171-linux-x64.tar.gz jdk1.8 - 配置环境变量
vim /etc/profile 在文件的末尾增加:
export JAVA_HOME=/root/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
刷新环境变量: source /etc/profile
测试java: java -version
网友评论