logo  

运维备忘录

运维备忘录
作者: 陈安廉

摘要:软件开发进阶系列


linux安装jdk


2021-02-22 10:49:15


http://www.bookerhome.com/book/101631905710001/content/106949174310001



linux安装java


1.创建文件夹/usr/local/java

2.上传jdk安装包到该文件夹

rz jdk-8u202-linux-x64.tar.gz


3.解压jdk

tar -zxvf jdk-8u202-linux-x64.tar.gz

4.设置环境变量

vim /etc/profile


在 profile 文件中添加如下内容并保存:


#set java environment

JAVA_HOME=/usr/local/java/jdk1.8.0_202

JRE_HOME=/usr/local/java/jdk1.8.0_202/jre

CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib

PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

export JAVA_HOME JRE_HOME CLASS_PATH PATH



vim ~/.bashrc

末尾追加
export JAVA_HOME=/usr/local/java/jdk1.8.0_202
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH


5.让修改生效:

source /etc/profile


6.测试

java -version



安装完毕之后看,如果openjdk为默认的,可按以下操作修改

https://blog.csdn.net/qq_36477176/article/details/123926255




jdk下载地址:

https://www.oracle.com/java/technologies/downloads/



  1. 右击要下载的版本,复制链接获取真实免登录下载地址。链接如下,文字加粗部分为 直链下载地址,但是需要登录
    https://www.oracle.com/webapps/redirect/signon?nexturl=https://download.oracle.com/otn/java/jdk/8u271-b09/61ae65e088624f5aaa0b1d2d801acb16/jdk-8u271-windows-x64.exe

  2. 替换直链中,otnotn-pub,真实直链下载地址为
    https://download.oracle.com/otn-pub/java/jdk/8u271-b09/61ae65e088624f5aaa0b1d2d801acb16/jdk-8u271-windows-x64.exe