Linux (CentOS) installation jdk8 tutorial

1. Uninstall the old jdk

1. Check if jdk is installed:

java -version

If the execution is wrong, it means that it is not installed, and skip directly to Chapter 2: Install the new jdk.

If the jdk version = 1.8, it meets the requirements and you can exit this installation directly, otherwise continue to go down.

2. View Java-related package information:

rpm -qa | grep java

3. Uninstall one by one:

rpm -e --nodeps [package name]

Such as:

rpm -e –nodeps tzdata-java-2017b-1.el7.noarch

4. Recheck to make sure all uninstalls are complete:

rpm -qa | grep java

Second, install the new jdk:

1. In any path, download jdk8:

wget -O jdk-8u161-linux-x64.tar.gz http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1523501764_2314b6b40aa1286690d7a8115ae8bf7a

Among them, AuthParam is dynamic, it is Oracle's anti-crawling measure, and one code can only be downloaded once.

If the above link is invalid, you can only go to Windows to download manually:

http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

You can download it to windows and then send it to linux, or copy the AuthParam parameters of the download link and use the wget command. The parameters at this time are definitely valid.

2. Unzip to the specified path:

mkdir -p /usr/lib/jvm
tar -zxvf jdk-8u161-linux-x64.tar.gz -C /usr/lib/jvm

3. Set environment variables

vim /etc/profile

Add at the end (where "jdk1.8.0_171" should be written according to the actual folder name):

exportJAVA_HOME=/usr/lib/jvm/jdk1.8.0_171

export JRE_HOME=${JAVA_HOME}/jre

exportCLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

4. Execute the profile file to make it take effect:

source /etc/profile

5. Check whether the installation is successful:

java -version

 


Guess you like

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