Install jdk correctly in centos and jdk in 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!
In CentOS, I installed JDK 17 and set the environment to change. echo can display my settings, but I still use java-version.
It is recommended to delete the previous JDK and export your Jdk environment variables in/etc/profile. However, my CentOS does not delete the previous jdk. The new version is available.
Install jdk-bash on CentOS: java: command not found
It may be a JDK installation error. You can uninstall it and reinstall it once. Javac, check whether