linux安装jdk

jdk下载位置
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
linux安装jdk_第1张图片

linux安装JDK

1,首先检测本机自带服务器,

[root@jdk-server ~]# java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

2,如果有自带首先卸载掉jdk

[root@jdk-server ~]# rpm -qa |grep java
tzdata-java-2020a-1.el7.noarch
javamail-1.4.6-8.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64
java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
javapackages-tools-3.4.1-11.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
javassist-3.16.1-10.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.262.b10-1.el7.x86_64
java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64

3,如果在卸载过程中删除掉这三个文件

[root@jdk-server ~]# rpm -e --nodeps tzdata-java-2020a-1.el7.noarch
[root@jdk-server ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64
[root@jdk-server ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64

4,解压jdk包

[root@jdk-server local] tar -zxvf jdk-8u291-linux-x64.tar.gz

5,配置jdk环境

[root@jdk-server ~]# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_291
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

6,重新添加配置文件

[root@jdk-server ~]# source /etc/profile

7,查看jdk

[root@jdk-server ~]# java -version
openjdk version "1.8.0_291"
OpenJDK Runtime Environment (build 1.8.0_291-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

你可能感兴趣的:(jdk,java,linux,centos)