Install Java 1.8 on CentOS

Source: Internet
Author: User

Install Java 1.8 on CentOS

Elasticsearch requires jdk 7 and later, and Oracle JDK version 1.8.0 _ 25 is recommended. This article describes how to install java 1.8 on CentOS.

More elasticsearch articles welcome to my blog: http://logos.name/

First, update the installed package:

yum update

View the current java version of the system:

java -version

If an old version is found, you can further query the installed JDK:

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

Rpm-qa indicates to query all installed packages. grep-E '^ (java | jdk)' uses a regular expression to filter the output results starting with java or jdk, the output may be 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

Run the following command to delete the old jdk:

yum remove java-1.6.0-openjdk

Download jdk from the official 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/8u65-b17/jdk-8u65-linux-x64.rpm"

After the new version, you need to add a cookie header to the download page to use wget for smooth download. You can select the version number on the official website.

Installation:

rpm -ivh jdk-8u65-linux-x64.rpm

After installation, confirm the default java version of the current system again:

If you see:

Java version "1.8.0 _ 65"

Java (TM) SE Runtime Environment (build 1.8.0 _ 65-b17)

Java HotSpot (TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Congratulations! The installation is successful.

Make sure that the environment variables are correct during each initialization:

vim/etc/profile.d/java.sh

Input:

#!/bin/bashJAVA_HOME=/usr/java/jdk1.8.0_65/PATH=$JAVA_HOME:$PATHexport PATH JAVA_HOME

After saving and exiting, add the executable permission for 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

This Digest self blog: http://logos.name/archives/439


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.