How to install jdk under centos

王林
Release: 2020-03-31 10:11:20
Original
4860 people have browsed it

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
Copy after login

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
Copy after login

3. Check whether the deletion has been successful

java -version
Copy after login
Copy after login

(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/
Copy after login

Note: Modify the permissions of the JDK compressed file before copying.

Type in the command line:

chmod 755 jdk-8u144-linux-x64.tar.gz
Copy after login

3. Unzip JDK

1. Type in the command window:

tar -zxvf jdk-8u144-linux-x64.tar.gz
Copy after login

2. Delete the JDK compressed package

Type in the command line:

rm -f jdk-8u144-linux-x64.tar.gz
Copy after login

4. Configure JDK environment variables

1. Edit global variables

Type in the command line:

vi /etc/profile
Copy after login

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
Copy after login

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
Copy after login

2. Check whether the configuration is successful.

Type:

java -version
Copy after login
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template