First, the problem description
Using CentOS is nothing more than a server, but the CentOS itself comes with OPENJDK, which is different from the JDK implementations of our usual sun (now Oracle), and we need to uninstall it. Otherwise, there will be different run results when calling Java or Javac commands.
Second, how to uninstall and install
1. First find out what the OPENJDK installation version already exists: Rpm-qa | grep JDK
Can see
There are two Java or JDK related software, at this point we need to try the rpm command to uninstall the software
2. Since both software has dependencies, so we try to force uninstall, regardless of the way
RPM-E--nodeps the corresponding name
3. Download the JDK installation package and unzip it into the/usr/local/java directory
Copy the tar.gz file to the/usr/local/java folder
Unziptar-xzvf. tar.gz file
4. Modify the configuration file Vim/ect/profile
Export java_home=/usr/local/javaexport CLASSPATH=.:$JAVA _home/jre/lib/rt.jar:$JAVA _home /lib/dt.jar:$JAVA _home/lib/tools.jarexport PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/ Usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:$JAVA _home/bin
Save exit: Wq
5. Allow profile configuration to take effect
Source/ect/profile
6. Check if Java is installed successfully
Java-version
Iii. problems that may arise
Java-version:
CentOS Java cannot execute binary file
You may have 64-bit installed, and the machine is 32-bit.
centos--Installing the JDK