1 first, find the default Java installation in centos
Whereis Java
Which Java (Java execution path)
Echo $ java_home
Echo $ path
2> View and uninstall:
Check if there is any Java command: rpm-Qa | grep Java
Delete if any: PM-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
Check whether JDK rpm-Qa | grep JDK is available.
Delete if any:
[[Email protected] USR] # rpm-Qa | grep JDK
Jdk-1.7.0_02-fcs.i586
[[Email protected] USR] # rpm-e -- nodeps jdk-1.7.0_02-fcs.i586
Check if there is any rpm-Qa | grep gcj
3 install
Rpm-IVH jdk-7u2-linux-i586.rpm
After the installation, a Java folder is automatically decompressed under/usr/, which has a jdk1.7.0 _ 02 folder.
4 Configuration
Add VI/etc/profile
Export java_home =/usr/Java/jdk1.7.0 _ 02
Export classpath =.: $ java_home/JRE/lib/RT. jar: $ java_home/lib/dt. jar: $ java_home/lib/tools. Jar
Export Path = $ path: $ java_home/bin
5 Test
[[Email protected] javacode] # javac test. Java
[[Email protected] javacode] # Java Test
Hello!