Linux服务器上如何安装jdk
jdk安装(rpm安装)
rpm下载地址https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
如果有安装openjdk 则卸载
[root@ran ~]# java -version
java version “1.8.0_121”
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
# 检查
[root@ran ~]# rpm -qa|grep jdk
jdk1.8.0_121-1.8.0_121-fcs.x86_64
# 卸载 -e –nodeps 强制删除
[root@ran ~]# rpm -e –nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64
[root@ran ~]# java -version
-bash: /usr/bin/java: No such file or directory # OK
3.开始安装JDK
# 安装java rpm
[root@ran ran]# rpm -ivh jdk-8u221-linux-x64.rpm
# 安装完成后配置环境变量 文件:/etc/profile
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64
CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JAVA_HOME
# 保存退出
# 让新增的环境变量生效!
source /etc/profile
# 测试 java -version
[root@ran java]# java -version
java version “1.8.0_221”
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
4.大功告成