CentOS 7 Installation Java 1.8

Source: Internet
Author: User

Ctrip's Apollo Configuration Center Server [Https://github.com/ctripcorp/apollo/wiki] recommended Java version is: 1.8+, this article describes how to install Java 1.8 on CentOS.

To view the current Java version of the system:

Java-version

If you find an older version, you can further query the JDK that the system has installed:

Rpm-qa | Grep-e ' ^ (JAVA|JDK) '

The RPM-QA representative queries all installed Packages,grep-e ' ^ (JAVA|JDK) to filter the output from a regular expression to the beginning of Java or JDK, and the output might 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 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

Oracle's official website download page need to add a cookie head to use wget smooth download, version number can be viewed on the official website, the latest stable version of the current jdk-8u161

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

[Email Protected]_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)

Ensure that the environment variables are correct each time you initialize:

vim /etc/profile.d/java.sh

Input:

#!/bin/bash
java_home=/usr/java/jdk1.8.0_161/
Path= $JAVA _home: $PATH
Export PATH Java_home

After saving exits, add executable permissions to the script:

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

The last script executes the settings for the environment variables to take effect:

source/etc/profile.d/java.sh

CentOS 7 Installation Java 1.8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.