centOS install jdk1.8

uninstall old version
rpm -qa | grep java | xargs rpm -e --nodeps 
Download the installation file
wget --no-check-certificate --no-cookie --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm

Because oracle now has to agree to the agreement to download, it can't be downloaded directly using wget plus link, so you need to add the previous code to
install the new version
rpm -ivh jdk-8u45-linux-x64.rpm



Here's how to install openjdk directly.
Because the performance and functions of openjdk have completely reached or even surpassed the official oracle jdk on linux, many core codes of oracle jdk versions are copied from openjdk, in this case, we can consider using openjdk when we use it.

Because centos comes with openjdk, we first determine the version of the currently installed jdk
rpm -qa|grep openjdk

Check out the list of versions available in the repository below
yum search openjdk

Select a higher version of jdk to install:
yum install -y  java-1.7.0-openjdk.x86_64
yum install -y  java-1.7.0-openjdk-devel.x86_64

Note that we should use java-1.7.0-openjdk-devel.x86_64 for development, which has development tools such as javac.
After the installation is complete, modify the alternatives to
view
alternatives --list
alternatives --display java

Revise
alternatives --config java

Select the current java version to be applied Add the JAVA_HOME variable
in /etc/profile and point to /etc/alternatives/java_sdk. When switching the java version in the future, java_home will remain unchanged, use the alternatives --config java command to switch

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326326373&siteId=291194637