银河麒麟安装JAVA JDK1.8

一、卸载open-jdk

1.首先查看系统是否自带Java

rpm -qa|grep java
rpm -qa|grep jdk
rpm -qa|grep gcj 

[root@localhost ~]# rpm -qa|grep java
java-1.8.0-openjdk-1.8.0.312.b07-10.ky10.x86_64
javapackages-filesystem-5.3.0-3.ky10.noarch
java-11-openjdk-headless-11.0.13.9-6.ky10.x86_64
java-1.8.0-openjdk-headless-1.8.0.312.b07-10.ky10.x86_64
javapackages-tools-5.3.0-3.ky10.noarch
java-11-openjdk-11.0.13.9-6.ky10.x86_64
tzdata-java-2021e-1.p02.ky10.noarch
[root@localhost ~]# rpm -qa|grep jdk
java-1.8.0-openjdk-1.8.0.312.b07-10.ky10.x86_64
java-11-openjdk-headless-11.0.13.9-6.ky10.x86_64
copy-jdk-configs-4.0-1.ky10.noarch
java-1.8.0-openjdk-headless-1.8.0.312.b07-10.ky10.x86_64
java-11-openjdk-11.0.13.9-6.ky10.x86_64
[root@localhost ~]# rpm -qa|grep gcj 
[root@localhost ~]# 

  查看jdk版本

[root@localhost ~]# java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment Bisheng (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM Bisheng (build 25.312-b07, mixed mode)

2.卸载jdk

[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.312.b07-10.ky10.x86_64

[root@localhost ~]# rpm -e --nodeps javapackages-filesystem-5.3.0-3.ky10.noarch
[root@localhost ~]# rpm -e --nodeps java-11-openjdk-headless-11.0.13.9-6.ky10.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.312.b07-10.ky10.x86_64
[root@localhost ~]# rpm -e --nodeps javapackages-tools-5.3.0-3.ky10.noarch
[root@localhost ~]# rpm -e --nodeps java-11-openjdk-11.0.13.9-6.ky10.x86_64
[root@localhost ~]# rpm -e --nodeps tzdata-java-2021e-1.p02.ky10.noarch

  查看java,没有任何输出表示已经卸载干净

[root@localhost ~]# java -version
-bash: /usr/bin/java: 没有那个文件或目录

[root@localhost ~]# rpm -qa|grep jdk
[root@localhost ~]# rpm -qa|grep java
[root@localhost ~]# rpm -qa|grep gcj

二、银河麒麟安装java JDK1.8

1.下载jdk1.8安装包

jdk-8u361-linux-x64.tar.gz

下载地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2.解压 jdk-8u361-linux-x64.tar.gz

tar -zxvf  jdk-8u361-linux-x64.tar.gz

3.创建并切换到安装目录

[root@localhost ~]# mkdir -p /usr/local/jdk

[root@localhost ~]# cd 桌面
[root@localhost 桌面]# ll
总用量 1040556
-rwxrwxrwx 1 root root 111367663 11月 25 2020 consul
-rwxrw-rw- 1 root root 41245292 2月 15 13:51 consul_1.9.0_linux_amd64.zip
drwxr-xr-x 8 root root 294 2月 20 16:14 jdk1.8.0_361

[root@localhost 桌面]# mv jdk1.8.0_361 /usr/local/jdk/jdk8
[root@localhost 桌面]# cd /usr/local/jdk/jdk8
[root@localhost jdk8]# ll
总用量 25824
drwxr-xr-x 2 root root 4096 2月 20 16:14 bin
-r--r--r-- 1 10143 10143 3244 1月 9 16:40 COPYRIGHT
drwxr-xr-x 3 root root 132 2月 20 16:14 include
-rw-r--r-- 1 10143 10143 5240876 1月 9 15:20 javafx-src.zip
-rw-r--r-- 1 10143 10143 195 1月 9 16:41 jmc.txt
drwxr-xr-x 6 root root 198 2月 20 16:14 jre
-rw-r--r-- 1 10143 10143 180 1月 9 16:41 jvisualvm.txt
drwxr-xr-x 4 root root 31 2月 20 16:14 legal
drwxr-xr-x 3 root root 207 2月 20 16:14 lib
-r--r--r-- 1 10143 10143 44 1月 9 16:40 LICENSE
drwxr-xr-x 4 root root 47 2月 20 16:14 man
-r--r--r-- 1 10143 10143 159 1月 9 16:40 README.html
-rw-r--r-- 1 10143 10143 127 1月 9 16:40 release
-rw-r--r-- 1 10143 10143 21163613 1月 9 16:40 src.zip
-rw-r--r-- 1 10143 10143 190 1月 9 15:20 THIRDPARTYLICENSEREADME-JAVAFX.txt
-r--r--r-- 1 10143 10143 190 1月 9 16:40 THIRDPARTYLICENSEREADME.txt

4.设置JDK环境变量

vim /etc/profile
在profile最后面追加java_home和path:

export JAVA_HOME=/usr/local/jdk/jdk8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

 按Esc退出编辑状态,然后输入:wq保存并退出文件

5.刷新配置文件,使配置文件产生作用

source /etc/profile
6.测试java是否安装成功

[root@localhost jdk8]# java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)

 查看版本号是java version "1.8.0_361"与jdk-8u361-linux-x64.tar.gz相同表示安装成功。

 

posted @ 2023-02-20 17:01  思江  阅读(7217)  评论(0编辑  收藏  举报