Home > Archives > Centos7安装jdk实战

Centos7安装jdk实战

Publish:

卸载已有openjdk

[root@localhost ~]# rpm -qa | grep java
[root@localhost ~]# rpm -e --nodeps jdk名称

安装指定Jdk

Java SE Downloads

[root@localhost ~]# mkdir /usr/java
[root@localhost ~]# cd /usr/java/
[root@localhost java]# >>> copy rpm file to this folder
[root@localhost java]# rpm -ivh /usr/java/jdk-8u112-linux-x64.rpm 

更新JAVA_HOME到profile文件尾

[root@localhost java]# vim /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_112
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

[root@localhost java]# source /etc/profile
[root@localhost java]# java -version
[root@localhost java]# $JAVA_HOME/bin/java -version
[root@localhost java]# echo $JAVA_HOME

参考资料

CentOS卸载系统自带的OpenJDK并安装Sun的JDK的方法

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: Ding Bao Guo