1. First determine whether it is 64-bit or 32-bit, and execute the command:
uname -a
The machine name contains x86_64, indicating that it is 64-bit
2. Download jdk and execute the command:
wget http://download.oracle.com/otn-pub/java/jdk/8u171-b11/512cd62ec5174c3487ac17c61aaa89e8/jdk-8u171-linux-x64.tar.gz?AuthParam=1524377800_aabc1e4c003ea9896c39e37216e2bef0
3. Unzip the installation
Unzip the execution command:
tar -zxvf jdk-8u171-linux-x64.tar.gz?AuthParam=1524377800_aabc1e4c003ea9896c39e37216e2bef0
Create a directory: /usr/local/java, put the decompressed java directory into it
4. Configure environment variables
vi /etc/profile
Append the following code to the end of the profile file:
# jdk8 settings
JAVA_HOME=/usr/local/jdk/jdk1.8.0_171
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib/dt.jar
export JAVA_HOME JRE_HOME PATH CLASSPATH
Enable new configuration
source /etc/profile
5. Enter java -version to view the version of the JDK