Install JDK8 in rpm on CentOS7

After CentOS 7 is successfully installed, the JRE of OpenJDK may have been installed by default, but a complete JDK is required for JAVA development. Therefore, in order to avoid unnecessary trouble in the future, I uninstalled the JRE of OpenJDK and reinstalled Oracle’s JDK8.

1. Installation Notes##

System environment: CentOS 7

Installation method: rpm

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

2. Check the original installed version of the system##

[ hadoop@centos7-1~]$ java -version
OpenJDK 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 java
libvirt-java-devel-0.4.9-4.el7.noarch
tzdata-java-2017b-1.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.131-3.b12.el7_3.x86_64
java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el7_3.x86_64
libvirt-java-0.4.9-4.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.1.el7_3.x86_64
java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64
python-javapackages-3.4.1-11.el7.noarch
[ hadoop@centos7-1~]$ 

3. Uninstall the installed openjdk

libvirt-java-devel-0.4.9-4.el7.noarch
libvirt-java-0.4.9-4.el7.noarch
tzdata-java-2017b-1.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.131-3.b12.el7_3.x86_64
java-1.7.0-openjdk-1.7.0.141-2.6.10.1.el7_3.x86_64
java-1.7.0-openjdk-headless-1.7.0.141-2.6.10.1.el7_3.x86_64
java-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_64

4. Install jdk

[ root@centos7-1 local]# ll /usr/local/jdk-8u131-linux-x64.rpm 
 - rw-r--r--.1 root root 1699834966 December 1223: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]# 

jdk is installed by default under /usr/java/

[ root@centos7-1 local]# ll /usr/java/
total 0
lrwxrwxrwx.1 root root 166 December 1223:18default->/usr/java/latest
drwxr-xr-x.9 root root 2686 Jan 1223:18 jdk1.8.0_131
lrwxrwxrwx.1 root root 226 Dec 1223:18 latest ->/usr/java/jdk1.8.0_131
[ root@centos7-1 local]# 

5. Verify installation##

[ root@centos7-1 local]# ll /usr/bin/java
lrwxrwxrwx.1 root root 226 Dec 1223:18/usr/bin/java ->/etc/alternatives/java
[ root@centos7-1 local]# ll /etc/alternatives/java
lrwxrwxrwx.1 root root 356, 1223:18/etc/alternatives/java ->/usr/java/jdk1.8.0_131/jre/bin/java
[ root@centos7-1 local]# java -version
java 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 environment variables##

[ hadoop@centos7-1~]$ whoami
hadoop
[ hadoop@centos7-1~]$ vi ~/.bashrc

Set JAVA_HOME and add it to PATH

JAVA_HOME=/usr/java/default
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH

Run the source command to make the modification effective. Output JAVA_HOME, PATH to confirm whether the modification takes 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

At this point, the installation of JDK8 on CentOS 7 has been successfully completed. For more articles about installing JDK under Linux, please check the relevant links below

Recommended Posts

Install JDK8 in rpm on CentOS7
How to install jdk1.8 on centOS7
Minimal install JDK 1.8 tutorial in CentOS 7
CentOS install jdk
How to install offline JDK1.8 on centos7.0
Install Docker on Centos7
install LNMP on centos7.4
Install Java on Centos 7
Install MySQL5.7 in centos7
Install php in centos
Nodejs install on centos7
Install FFmpeg on CentOS 8
Install RabbitMQ on CentOS 7
Install Node.js on Centos
Linux Centos7 install jdk1.8
Maven install on centos7
Install MongoDB on CentOS 7
Install Surelog on CentOS8
CentOS7 install JDK8, tomcat8
Install redis5.0 in CentOS7
Install JDK10+ on Ubuntu
Install JDK in Ubuntu19.10
Openjdk install on centos7
Install Jenkins on centos7
install RabbitMQ on centos
Install RabbitMQ on CentOS 7
install Docker on centos6.5
install oracle on centos
Install Elasticsearch 6 on centos7
Install RabbitMQ on CentOS7
Centos 7 install JDK (Linux install jdk)
CentOS Discovery Road 2---Use rpm to install JDK
How to install RPM packages on CentOS Linux
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
Install mysql online on centos
Install ElasticSearch 7.x on CentOS 7
CentOS 7 install JAVA environment (JDK 1.8)
Install MySQL 8.0.16 on Linux Centos
Install docker transfer on Centos7
Tencent Cloud Centos install jdk8
Install docker on Centos system
Install Java JDK8 under CentOS6
install EPEL repo on centos
Install Zabbix 3.4 based on CentOS 7
install virtualbox on centos server
5.1. CentOS@ install JDK1.8 graphic tutorial
Install Nginx server on CentOS 7
Centos 7 install jdk and package service service
How to install Memcached on CentOS 8
Install MATE or XFCE on CentOS 7
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install PHP7.4 in CentOS
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
Install MySql with Docker in CentOS7