1. Check the openjdk installation package first.
$ Rpm-Qa | grep Java
Tzdata-java-2013b-1.el6.noarch
Java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64
Java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64
2. Check the openjdk version.
$ Java-version
Java version "1.7.0 _ 19"
Openjdk Runtime Environment (rhel-2.3.9.1.el6_4-x86_64)
Openjdk 64-bit server VM (build 23.7-b01, mixed mode)
3. Uninstall openjdk
Log on to the terminal as a root user
$ Su Root
Password:
$ Rpm-e -- nodeps java-1.7.0-openjdk-1.7.0.19-2.3.9.1.el6_4.x86_64.
$ Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.61.1.11.11.el6_4.x86_64.
$ Rpm-e -- nodeps tzdata-java-2013b-1.el6.noarch.
4 install jdk-7u17-linux-x64.rpm
: Http://pan.baidu.com/share/link? Consumer id = 397488 & UK = 638583574
$ CD/jdk1.7 directory
$ Rpm-IVH jdk-7u17-linux-x64.rpm
Preparing... ######################################## ### [100%]
1: JDK ####################################### #### [100%]
Unpacking jar files...
Rt. jar...
Error: cocould not open input file:/usr/Java/jdk1.7.0 _ 17/JRE/lib/RT. Pack
JSSE. jar...
Error: cocould not open input file:/usr/Java/jdk1.7.0 _ 17/JRE/lib/JSSE. Pack
Charsets. jar...
Error: cocould not open input file:/usr/Java/jdk1.7.0 _ 17/JRE/lib/charsets. Pack
Tools. jar...
Error: cocould not open input file:/usr/Java/jdk1.7.0 _ 17/lib/tools. Pack
Localedata. jar...
Error: cocould not open input file:/usr/Java/jdk1.7.0 _ 17/JRE/lib/EXT/localedata. Pack
The preceding errors can be ignored without affecting JDK installation and use.
5. Configure Environment Variables
$ VI/etc/profile
Input O and add the following content at the end:
Java_home =/usr/Java/jdk1.7.0 _ 17
Jre_home =/usr/Java/jdk1.7.0 _ 17/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
Make environment variables take effect immediately
$ Source/etc/profile
6. test whether the installation is successful.
Enter Java, Java-version, and javac in sequence to view the output information, for example
[Root @ chenpc-cent tools] # Java-version
Java version "1.7.0 _ 17"
Java (TM) se Runtime Environment (build 1.7.0 _ 17-b02)
Java hotspot (TM) 64-bit server VM (build 23.7-b01, mixed mode) topic: centos6.4 install JDK