Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Install JDK8 in rpm mode on CentOS7

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

CentOS 7 may have installed OpenJDK JRE by default after successful installation, but usually Java development needs to use a complete JDK, so in order to avoid unnecessary trouble in the future, uninstall OpenJDK JRE here, and reinstall Oracle JDK8

1. installation instructions

System environment: CentOS 7

Installation mode: rpm

Installation package: jdk-8u131-linux-x64.rpm

2. Check system original installation version [hadoop@centos7-1 ~]$ java -versionOpenJDK Version "1.8.0_131"OpenJDK Runtime Environment (build 1.8.0_131-b12)OpenJDK 64-Bit Server VM (build 25.131-b12, mixed mode)[hadoop@centos7-1 ~]$ rpm -qa| grep javalibvirt-java-devel-0.4.9-4.el7.noarchtzdata-java-2017b-1.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.131-3.b12.el7_3.x86_64java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el7_3.x86_64libvirt-java-0.4.9-4.el7.noarchjavapackages-tools-3.4.1-11.el7.noarchjava-1.7.0-openjdk-headless-1.7.0.141-2.6.10.1.el7_3.x86_64java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64python-javapackages-3.4.1-11.el7.noarch[hadoop@centos7-1 ~]$3. Uninstall the installed openjdklibvirt-java-devel-0.4.9-4.el7. nolibarchvirt-java-0.4.9- 4.el7.noarchtzdata-java-2017b-1.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.131-3.b12.el7_3.x86_64java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el7_3.x86_64java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.1.el7_3.x86_64java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64

Run the following command as root

[root@centos7-1 hadoop]# rpm -e --nodeps libvirt-java-devel-0.4.9-4.el7.noarch[root@centos7-1 hadoop]# rpm -e --nodeps libvirt-java-0.4.9-4.el7.noarch[root@centos7-1 hadoop]# rpm -e --nodeps tzdata-java-2017b-1.el7.noarch[root@centos7-1 hadoop]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.141- 2.6.10.1.el7_3.x86_64[root@centos7-1 hadoop]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el7_3.x86_64[root@centos7-1 hadoop]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.131-3.b12.el7_3.x86_64[root@centos7-1 hadoop]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_644. install jdk[root@centos7-1 local]#ll/usr/local/jdk-8u131-linux-x64.rpm-rw-r--. 1 root root 169983496 Jun 12 23:17 /usr/local/jdk-8u131-linux-x64.rpm[root@centos7-1 local]# rpm -ivh jdk-8u131-linux-x64.rpm Preparing.. ################################# [100%] Updating / installing... 1:jdk1.8.0_131-2000:1.8.0_131-fcs ################################# [100%] Unpacking JAR files... tools.jar... plugin.jar... javaws.jar... deploy.jar... rt.jar... jsse.jar... charsets.jar... localedata.jar... [root@centos7-1 local]#

The requested URL/java/was not found on this server.

[root@centos7-1 local]# ll /usr/java/total 0lrwxrwxrwx. 1 root root 16 Jun 12 23:18 default -> /usr/java/latestdrwxr-xr-x. 9 root root 268 Jun 12 23:18 jdk1.8.0_131lrwxrwxrwx. 1 root root 22 Jun 12 23:18 latest -> /usr/java/jdk1.8.0_131[root@centos7 -1 local]# 5. Verify installation [root@centos7-1 local]# ll /usr/bin/javalrwxrwx. 1 root root 22 Jun 12 23:18 /usr/bin/java -> /etc/alternatives/java[root@centos7-1 local]# ll /etc/alternatives/javalrwxrwx. 1 root 35 Jun 12 23:18 /etc/alternatives/java -> /usr/java/jdk1.8.0_131/jre/bin/java[root@centos7-1 local]# java -versionjava version "1.8.0_131"Java(TM) SE Runtime Environment (build 1.8.0_131-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)[root@centos7-1 local]# 6. Configure environmental variables [hadoop@centos7 - 1 ~]$ whoamihadoop[hadoop@centos7 - 1 ~]$ vi ~/.bashrc

Set JAVA_HOME and add it to PATH

JAVA_HOME=/usr/java/defaultPATH=$PATH:$JAVA_HOME/binexport JAVA_HOME PATH

Run the source command to make the changes take effect. Output JAVA_HOME, PATH to confirm whether the changes take effect.

[hadoop@centos7-1 ~]$ source ~/.bashrc[hadoop@centos7-1 ~]$ echo $JAVA_HOME/usr/java/default[hadoop@centos7-1 ~]$ echo $PATH/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/hadoop/.local/bin:/home/hadoop/bin:/usr/java/default/bin

So far, the installation of JDK8 on CentOS 7 has been successfully completed. For more articles on installing JDK under Linux, please see the following related links.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report