Step 1: Check whether the built-in JDK of Linux is installed (uninstall centOS 1.4 installed). after CentOS is installed, it comes with OpenJdk. run the java-version command. the following information is displayed: javaversion & quot; 1.6.0 & quot; OpenJDKRuntimeEnvironment (build1.6.0-b09) OpenJDK64-BitS
Step 1: Check whether the built-in JDK of Linux is installed (uninstall centOS 1.4 installed)
The installed CentOS comes with OpenJdk and uses the java-version command. the following information is displayed:
Java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)
It is best to uninstall openjdk first and install the jdk of sun.
Check rpm-qa | grep java first
The following information is displayed:
Java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
Uninstall:
Rpm-e -- nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
There are other commands
Rpm-qa | grep gcj
Rpm-qa | grep jdk
If openjdk source cannot be found, you can uninstall it like this.
Yum-y remove java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5
<1> # rpm-qa | grep jdk plugin to view jdk information or directly execute
Or
# Rpm-q jdk
Or
# Java-version
<2> # rpm-qa | grep gcj release confirm the gcj version number
<3> # yum-y remove java-1.4.2-gcj-compat uninstall gcj
Step 2: install SUN's JDK.
Official website: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Create a java directory under/usr to install the java program in this directory. enter the following command:
Linux code
- Mkdir/usr/java
Copy the downloaded file to the/usr/java directory and enter the following command:
[Plain]View plaincopy
- [Root @ localhost java] # mv/home/ivan/Downloads/jdk-7u60-linux-x64.rpm/usr/java
- [Root @ localhost java] # ls
- Jdk-7u60-linux-x64.rpm
- [Root @ localhost java] # rpm-ivh jdk-7u60-linux-x64.rpm
- Preparing... ######################################## ### [100%]
- 1: jdk ####################################### #### [100%]
- Unpacking JAR files...
- Rt. jar...
- Jsse. jar...
- Charsets. jar...
- Tools. jar...
- Localedata. jar...
- Jfxrt. jar...
- [Root @ localhost java] # ls
- Default jdk1.7.0 _ 60 jdk-7u60-linux-x64.rpm latest
Enter the following command to enter the configuration file.
[Root @ localhost java] # vi/etc/profile
Add
Export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
Export JAVA_HOME =/usr/java/jdk1.7.0 _ 60
Export PATH = $ JAVA_HOME/bin: $ PATH
Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
Make environment variables take effect.
Execute the configuration file to make it take effect immediately. enter the following command:
[Root @ localhost java] # source/etc/profile
View the version currently installed in java
[Root @ localhost java] # java-version
Java version "1.7.0 _ 60"
Java (TM) SE Runtime Environment (build 1.7.0 _ 60-b19)
Java HotSpot (TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
This article references http://hermosa-young.iteye.com/blog/1798026