1. First check that the JDK is not the default
Or
# rpm-qa|grep Java
Discover that there is no Java
There is no, if it is installed with a virtual machine, there may be openjdk, you need to uninstall and install it first.
2. Download Java to the server
I first downloaded from the Java official website and then connected to the server via SECURECRT to copy the files to the server.
Copy to/usr/local/java inside.
3. Unzip
Then execute # TAR-ZXVF jdk-8u171-linux-x64.tar.gz
You can see one more folder underneath the Java folder jdk1.8.0_171
4. Configure Environment variables
# Vi/etc/profile
java_home=/usr/local/java/jdk1.8.0_171
Jre_home=/usr/local/java/jdk1.8.0_171/jre
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Classpath=: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Export Java_home jre_home PATH CLASSPATH
Execute # source/etc/profile make code effective
You can view the environment variables by using the # echo $PATH
Or the # echo $JAVA _home
Java-version javac-version
So Java is installed.
centerOs6.5 Installing Java