Install jdk correctly on centos
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:
[Root @ luozhonghua usr] # rpm-qa | grep jdk
Jdk-1.7.0_02-fcs.i586
[Root @ luozhonghua 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
[Root @ luozhonghua javacode] # javac test. java
[Root @ luozhonghua javacode] # java test
Hello!