Home > Article > Operation and Maintenance > How to install jdk under centos
The specific method is as follows:
1. Uninstall the OpenJDK and related java files that come with the system
1. Type in the command window:
rpm -qa | grep java
2. Delete the original java file and type in the command window:
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64 rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64 rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64 rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64
3. Check whether the deletion has been successful
java -version
(recommended tutorial: centos tutorial)
2. Download the latest stable JDK
1. The download address is
http:// www.oracle.com/technetwork/java/javase/archive-139210.html
2. After the download is complete, copy the JDK compressed package to /usr/local/src/ for backup
cp jdk-8u144-linux-x64.tar.gz /usr/local/src/
Note: Modify the permissions of the JDK compressed file before copying.
Type in the command line:
chmod 755 jdk-8u144-linux-x64.tar.gz
3. Unzip JDK
1. Type in the command window:
tar -zxvf jdk-8u144-linux-x64.tar.gz
2. Delete the JDK compressed package
Type in the command line:
rm -f jdk-8u144-linux-x64.tar.gz
4. Configure JDK environment variables
1. Edit global variables
Type in the command line:
vi /etc/profile
2. Add the following text:
#java environment export JAVA_HOME=/usr/java/jdk1.8.0_144 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. Let the environment variables just set take effect and check whether the installation is successful
1. Make the environment variables just set take effect.
Type:
source /etc/profile
2. Check whether the configuration is successful.
Type:
java -version
Recommended related video tutorials: linux video tutorial
The above is the detailed content of How to install jdk under centos. For more information, please follow other related articles on the PHP Chinese website!