Check JDK version, uninstall OPENJDK version (JDK and openjdk differences do not repeat here)
Check the java–version, javac–version command view version first (figure I)
After checking JDK version 1.7.0.45; then enter Rpm-qa|grep Java view (figure II)
Note: The OPENJDK version installed in different CentOS versions may differ; If there are no listings, look at step 4th directly.
Uninstall the above three files (requires root, login root to uninstall) (Figure III)
RPM-E--nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64
RPM-E--nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64
RPM-E--nodeps Tzdata-java-2013g-1.el6.noarch
View JDK information again (Figure IV)
You are now ready to install the Oracle version of the JDK.
or direct command download:
[Root@vm_16_4_centos home]# wget--no-check-certificate--no-cookies--header "cookie:oraclelicense= Accept-securebackup-cookie "http://download.oracle.com/otn-pub/java/jdk/8u162-b12/ 0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.tar.gz
Extract JDK, extract command: Tar-xvzf jdk-7u25-linux-x64.tar.gz
JDK location:/home/codebrother/jdk/jdk-7u25-linux-x64.tar.gz, after the current path decompression, decompression, will appear JDK folder, access to the JDK directory, and view the contents of the content (such as Figure V)
Configuring JDK Environment variables
In a Linux system, you need to add the JDK's Bin directory in path, create Classpath, and add the JDK's lib directory.
Home directory for JDK:/home/codebrother/jdk/jdk1.7.0_25
JDK's Bin directory:/home/codebrother/jdk/jdk1.7.0_25/bin
Lib directory for JDK:/home/codebrother/jdk/jdk1.7.0_25/lib
Edit ~/.BASHRC File
Command:
VI ~/.BASHRC
Add the following variables (Figure VI)
Export java_home=/home/codebrother/jdk/jdk1.7.0_25
export java_bin= $JAVA _home/bin
Export java_lib= $JAVA _ Home/lib
export classpath=.: $JAVA _lib/tools.jar: $JAVA _lib/dt.jar
export path= $JAVA _bin: $PATH
Press ESC, and then: Wq Save exit
Make JDK environment variables effective, source ~/.BASHRC (Figure Seven)
View JDK version
Enter Java-version, javac-version (Figure Eight)