decompress jdk
Open the terminal in the jdk folder and enter the pwd command to copy the path of the jdk
Obtain root privileges and enter /etc Modify the profile text in /etc and
add the following at the end
export JAVA_HOME=/home/runqi/jdk1.8.0_161
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
Load the variable just set
Terminal input command source /etc/profile
Enter java -version to check whether the configuration is successful