CentOS 7 install Java 1.8

The recommended Java version of Ctrip's Apollo Configuration Center server [https://github.com/ctripcorp/apollo/wiki] is 1.8+. This article describes how to install java 1.8 on CentOS.

View the current java version of the system:

java -version

If it is found to be an old version, you can further query the JDK installed on the system:

rpm -qa | grep -E '^(java|jdk)'

rpm -qa means to query all installed packages, grep -E'^(java|jdk)' uses regular expressions to filter the results starting with java or jdk in the output. The output may look like this:

java-1.6.0-openjdk-1.6.0.37-1.13.9.4.el6_7.x86_64

java-1.6.0-openjdk-devel-1.6.0.37-1.13.9.4.el6_7.x86_64

You can delete the old jdk with the following command

yum remove java-1.6.0-openjdk

Download jdk from oracle official website:

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.rpm

The download page of Oracle's official website needs to add a cookie header to successfully download with wget. The version number can be selected after browsing on the official website. The current stable version jdk-8u161

Installation: rpm -ivh jdk-8u161-linux-x64.rpm

[ root@VM_48_111_centos data]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Make sure that the environment variables are correct every time you initialize:

vim /etc/profile.d/java.sh

enter:

#! /bin/bash
JAVA_HOME=/usr/java/jdk1.8.0_161/
PATH=JAVA_HOME:PATH
export PATH JAVA_HOME

After saving and exiting, add executable permissions to the script:

chmod 744/etc/profile.d/java.sh

Finally, execute the script to make the environment variable settings take effect:

source /etc/profile.d/java.sh

Recommended Posts

CentOS 7 install Java 1.8
CentOS 7 install Java 1.8
Install Java on Centos 7
1.5 Install Centos7
CentOS 7 install JAVA environment (JDK 1.8)
CentOS6.5 install Java 8 and Tomcat8
Install Java JDK8 under CentOS6
CentOS6.5 install Java 8 and Tomcat8
Centos6 install Python2.7.13
Centos7.3 install nginx
CentOS7.2 install Mysql5.7.13
CentOS install Redmine
Centos7 install Python 3.6.
CentOS7 install MySQL
Centos7 install protobuf
CentOS 7 install Docker
CentOS7 install GlusterFS
CentOS 7.4 install Zabbix 3.4
CentOS7 install Docker
Centos6.5 install Tomcat
CentOS install Python 3.6
Tencent Cloud Centos7 install java server
Vmware install CentOS6
centos7 install docker-ce 18.01.0
CentOS 7.2 install MariaDB
CentOS 7 install Hadoop 3.0.0
Tencent Cloud Centos7 install java server
Centos 7.6 install seleniu
Install java in yum mode in Centos
CentOS 7.3 install Zabbix3
CentOS install mysql
CENTOS6.5 install CDH5.12.1 (1)
CentOS6 install mist.io
Centos7 install Docker
CentOS7 install mysql
centOs install rabbitMQ
CentOS 7 install MySQL 5.6
Centos7 install Nginx
CentOS6.5 install CDH5.13
Centos7 install docker18
Centos install Python3
centos7 install docker
CentOS install jdk
centos7 install nginx-rtmp
CentOS8 install MySQL8.0
Centos6.3 install KVM
CentOS install PostgreSQL 9.1
CentOS7 install mysql8
CentOS8 install fastdfs6.06
CentOS 7 install Gitlab
Centos 7 install PostgreSQL
CentOS7 install MySQL8
CentOS 6 install Docker
centos 6.5 install zabbix 4.4
Centos8 install Docker
CentOS6.8 install python2.7
CentOS install nodejs 8
CentOS6.5 install GNS3
centos 7.5 install mysql5.7.17
Centos7 install MySQL8.0-manual
CentOS7 install Kubernetes 1.16.3