Install jdk8 rpm under Linux cloud server

jdk installation (rpm installation)

1. rpm download address

http://www.oracle.com/technetwork/java/javase/downloads/index.html
upload files to /home's self-created directory via xftp

2. Uninstall if openjdk is installed

First check the version
java --version

[root@kuangshen ~]# 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@kuangshen ~]# rpm -qa|grep jdk
jdk1.8.0_121-1.8.0_121-fcs.x86_64
# 卸载 -e --nodeps 强制删除
[root@kuangshen ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64
[root@kuangshen ~]# java -version
-bash: /usr/bin/java: No such file or directory  # OK

3. Install JDK

# 安装java rpm
[root@kuangshen kuangshen]# rpm -ivh jdk-8u221-linux-x64.rpm

4. Configure environment variables after installation

Click on the session, and then open a window to query java

[root@VM-0-16-centos ~]# cd /usr/local
[root@VM-0-16-centos local]# ls
bin  etc  games  include  lib  lib64  libexec  qcloud  sbin  share  src  yd.socket.server
[root@VM-0-16-centos local]# cd /usr
[root@VM-0-16-centos usr]# ls
bin  etc  games  include  java  lib  lib64  libexec  local  sbin  share  src  tmp
[root@VM-0-16-centos usr]# cd java
[root@VM-0-16-centos java]# ls
default  jdk1.8.0_281-amd64  latest
[root@VM-0-16-centos java]# cd jdk1.8.0_281-amd64/
[root@VM-0-16-centos jdk1.8.0_281-amd64]# ls
bin        javafx-src.zip  legal    man          src.zip
COPYRIGHT  jmc.txt         lib      README.html  THIRDPARTYLICENSEREADME-JAVAFX.txt
include    jre             LICENSE  release      THIRDPARTYLICENSEREADME.txt
[root@VM-0-16-centos jdk1.8.0_281-amd64]# 

Find java information jdk1.8.0_281-amd64 here
and write configuration information

[root@VM-0-16-centos hxl]# vim /etc/profile

Add at the end after entering

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

Then click esc: wq save and exit

Let the new environment variables take effect!

source /etc/profile

Test java -version

[root@VM-0-16-centos hxl]# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)
[root@VM-0-16-centos hxl]# 

Guess you like

Origin blog.csdn.net/he1234555/article/details/114399829