centos7配置java环境

java软件包下载地址:
链接:https://pan.baidu.com/s/1NHGf1q__0KCpbNktJDF7Ew
提取码:vhwi

echo "具体软件名称和路径根据实际情况而定"

cd /usr/local/src

tar -zxv -f jdk-8u221-linux-x64.tar.gz -C /usr/local/

vim /etc/profile.d/java.sh

#!/bin/bash

export JAVA_HOME=/usr/local/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre  
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib  
export PATH=${JAVA_HOME}/bin:$PATH

source /etc/profile.d/java.sh

echo ${JAVA_HOME}

java -version

另一种:

export JAVA_HOME=/usr/local/jdk1.8.0_171/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

高版本的设置:

vim /etc/profile.d/java.sh

#!/bin/bash

export JAVA_HOME=/usr/local/jdk-17.0.2
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
posted @ 2020-03-19 11:05  哈喽哈喽111111  阅读(1707)  评论(0编辑  收藏  举报