1、获取jdk1.8安装包,上传到服务器,后续放置在/usr/local/java目录下
[root@localhost ~]# mkdir /usr/local/java
[root@localhost ~]# cd /usr/local/java
2、解压
[root@localhost java]# tar -zxvf jdk-8u341-linux-x64.tar.gz
3、配置环境变量
[root@localhost java]# vi /etc/profile
#JAVA环境变量
export JAVA_HOME=/usr/local/java/jdk1.8.0_341
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
4、生效
[root@localhost java]# source /etc/profile
5、查验
[root@localhost java]# java -version
报错:
which: no java in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/geoscene/.local/bin:/home/geoscene/bin)
ERROR: Could not locate Java in path.
把JAVA_HOME下的bin/java,软连接到/usr/bin/java(本次还授予了/home/geoscene/jdk1.8.0_341,,777权限)文章来源:https://www.toymoban.com/news/detail-524344.html
[root@geoenterprise geoscene]# ln -s /home/geoscene/jdk1.8.0_341/bin/java /usr/bin/java
文章来源地址https://www.toymoban.com/news/detail-524344.html
到了这里,关于Centos7安装配置jdk1.8的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!