1.执行Linux命令 -----vim /etc/profile 编辑profile 文件,在里面添加:
#set java enviroment
JAVA_HOME=/opt/JavaHome/jdk1.8.0_171JRE_HOME=/opt/JavaHome/jdk1.8.0_171/jreCLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binexport JAVA_HOME JRE_HOME CLASS_PATH PATH2.执行Linux命令 --- source /etc/profile刷新修改后的配置文件
执行 java -version 查看安装的java版本报错: bash: /home/jdk1.8.0_161/bin/java: Permission denied[root@izuf6c6nw8nng69p6ui5mcz ~]# cd /opt/JavaHome/[root@izuf6c6nw8nng69p6ui5mcz JavaHome]# lsjdk1.8.0_171[root@izuf6c6nw8nng69p6ui5mcz JavaHome]# java -version-bash: /opt/JavaHome/jdk1.8.0_171/bin/java: Permission denied[root@izuf6c6nw8nng69p6ui5mcz JavaHome]# chmod 777 jdk1.8.0_171/bin/java(重点)[root@izuf6c6nw8nng69p6ui5mcz JavaHome]# java -versionjava version "1.8.0_171"Java(TM) SE Runtime Environment (build 1.8.0_171-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)