centos安装jdk

https://www.cnblogs.com/taohaijun/p/7153176.html

https://blog.csdn.net/hui_2016/article/details/69941850

https://blog.csdn.net/fuyuwei2015/article/details/73195936

1.   查看已经安装的jdk

rpm -qa|grep jdk

rpm -qa|grep java

如果有,卸载:

rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64

2.  上传并安装

rpm -ivh jdk-8u162-linux-x64.rpm

3.  检查

java -version

4.  配置环境变量

在/etc/profile文件末尾添加:

export JAVA_HOME=/usr/java/jdk1.8.0_162

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

使/etc/profile生效:

source /etc/profile

相关推荐