1. Uninstall the jdk that comes with Linux
1. To check whether jdk already exists in the virtual machine, enter the command:
java -version
2. View the installation package:
rpm -qa | grep java
3. If yes, uninstall jdk (choose one of the methods):
# 挨个删除每一个包
rpm -e --nodeps 包名
# 一次性删除
yum remove *openjdk*
4. Verify whether it is uninstalled:
Two, download jdk
1. Method 1: Download online, save the jdk compressed package in the /usr/local/ directory, and download the command:
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm
2. Method 2: Transfer to Linux system after Windows download:
Download URL: Java Downloads | Oracle
Network disk acquisition: Link: https://pan.baidu.com/s/1xn3R29Oyylypp1TepRz4Rw
Extraction code: 4aj3
After the download is complete, put it in the /usr/local/jdk directory:
3. Unzip and install
Shortcut keys in xshell:
Copy: Ctrl+insert
Paste: shift+insert
(1) Unzip the file:
tar -zxvf jdk-8u341-linux-x64.tar.gz
(2) Configure environment variables
vi /etc/profile
Press the keyboard 'i' to enter the editing state;
Add the following configuration to the last line of the file profile, note: JAVA_HOME= corresponds to your own jdk storage path
After inputting, press Esc to exit editing, press ":wq" to save and exit;
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_341
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
(3) Refresh the configuration file
source /etc/profile
(4) Check whether the installation is successful
java -version
When the above interface appears, it means that the installation has been successful! ! !
(When your hair gets thinner, you get stronger!)