java环境配置

  • 第1步,下载并解压 java 1.8.0-391,虽然jar包不区分arm或x86架构,但是java安装包分arm版或x86版,下面以 x86_64 为例
mkdir -p /usr/local/java
curl -L http://iso.sqlfans.cn/jdk/jdk-8u391-linux-x86_64.tar.gz -o /opt/jdk-8u391-linux-x86_64.tar.gz
tar -zxf /opt/jdk-8u391-linux-x86_64.tar.gz -C /usr/local/java/ 2> /dev/null
ln -sv /usr/local/java/jdk1.8.0_391 /usr/local/java/openjdk8
  • 第2步,配置环境变量
if [ `cat /etc/profile | grep java | grep openjdk8 | wc -l` = "0" ];then 
    echo 'export JAVA_HOME=/usr/local/java/openjdk8' >> /etc/profile
    echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
    echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
fi
source /etc/profile
  • 第3步,确认java版本
[root@localhost ~]# java -version
java version "1.8.0_391"
Java(TM) SE Runtime Environment (build 1.8.0_391-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.391-b13, mixed mode)
Copyright © www.sqlfans.cn 2024 All Right Reserved更新时间: 2023-12-07 13:20:52

results matching ""

    No results matching ""