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=
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