Linux安装jdk

去官网找下载地址

jdk1.8地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

点击打开jdk1.8官网

下载jdk

我的jdk通常放在 /usr/local/java 下
[root@izm5ea6vx1xwu8esanrekvz java]# wget https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1543200147_8cbc113f1526e1b7aacc726c47947217

centos中用wget下载文件

解压

tar -avxf jdk-8u191-linux-x64.tar.gz\?AuthParam\=1543200147_8cbc113f1526e1b7aacc726c47947217

配置环境变量

vim /etc/profile 打开配置文件,在文件最后添加(ins进入编辑添加,Ctrl+C退出编辑,:wq保存 ,:wq!不保存):

export JAVA_HOME=/usr/local/java/jdk1.8.0_191

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH


生效配置

source /etc/profile

验证

[root@izm5ea6vx1xwu8esanrekvz java]# source /etc/profile
[root@izm5ea6vx1xwu8esanrekvz java]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
[root@izm5ea6vx1xwu8esanrekvz java]# 
# linux   java   环境变量  

评论

企鹅群:39438021

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×