欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

CentOS安装Java环境(脚本一键式安装)

程序员文章站 2022-06-28 16:35:33
1、上传jdk-8u251-linux-x64.tar.gz到/opt/java目录下2、在/opt/java目录下创建install.sh文件,内容如下:#!/bin/bashtar zxvf /opt/java/jdk-8u251-linux-x64.tar.gz -C /opt/java > /dev/null 2>&1echo '# JAVA-8u251' >> /etc/profileecho 'JAVA_HOME=/opt/java/jdk1.....

1、上传jdk-8u251-linux-x64.tar.gz到/opt/java目录下

2、在/opt/java目录下创建install.sh文件,内容如下:

#!/bin/bash
tar zxvf /opt/java/jdk-8u251-linux-x64.tar.gz -C /opt/java > /dev/null 2>&1
echo '# JAVA-8u251' >> /etc/profile
echo 'JAVA_HOME=/opt/java/jdk1.8.0_251' >> /etc/profile
echo 'JAVA_BIN=/opt/java/jdk1.8.0_251/bin' >> /etc/profile
echo 'PATH=$PATH:$JAVA_BIN' >> /etc/profile
echo 'CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
echo 'export JAVA_HOME JAVA_BIN PATH CLASSPATH' >> /etc/profile
source /etc/profile
echo "java is already installed,please open another session to test it "

3、执行install脚本即可

sh install.sh

本文地址:https://blog.csdn.net/joshho/article/details/109649284

相关标签: Java