Check the jdk version, uninstall the openjdk version (the difference between jdk and openjdk is not repeated here)
First check the java -version, javac -version
commands to view the version (Figure 1)
After checking the jdk version is 1.7.0.45; then enter rpm -qa|grep java
to view (Figure 2)
Note: The openjdk version installed by different CentOS versions may be different; if there is no list displayed, you can go directly to step 4
Uninstall the above three files (root privileges are required, login with root privileges to uninstall) (Figure 3)
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
Check the jdk information again (Figure 4)
Now you are ready to install the Oracle version of jdk.
Or order to download directly:
[ 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
Unzip the jdk, unzip the command: tar -xvzf jdk-7u25-linux-x64.tar.gz
The location of jdk: /home/codebrother/jdk/jdk-7u25-linux-x64.tar.gz
, unzip in the current path, after unzip, the jdk folder will appear, enter the jdk directory, and view the contents of the directory ( Figure 5)
Configure jdk environment variables
In the Linux system, you need to add the jdk bin directory in the PATH, create a CLASSPATH, and add the jdk lib directory.
Jdk's home directory: /home/codebrother/jdk/jdk1.7.0_25
The bin directory of jdk: /home/codebrother/jdk/jdk1.7.0_25/bin
The lib directory of jdk: /home/codebrother/jdk/jdk1.7.0_25/lib
Edit ~/.bashrc file
command:
vi ~/.bashrc
Add the following variables (Figure 6)
export JAVA_HOME=/home/codebrother/jdk/jdk1.7.0_25export JAVA_BIN=$JAVA_HOME/binexport JAVA_LIB=$JAVA_HOME/libexport CLASSPATH=.:$JAVA_LIB/tools.jar:$JAVA_LIB/dt.jarexport PATH=$JAVA_BIN:$PATH
Press the ESC key, then: wq save and exit
Make jdk environment variables take effect, source ~/.bashrc (Figure 7)
View jdk version
Enter java -version, javac -version
(Figure 8)
to sum up
The above is the JDK environment variable configuration method under ubuntu introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
Recommended Posts