JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home PATH=$JAVA_HOME/bin:$PATH //给环境变量赋值 export JAVA_HOME //导出使其生效 export PATH 参考链接：https://blog.csdn.net/m0_51520179/article/details/131295356
1.打开系统环境变量配置2.添加 JAVA_HOMED:\Program Files\Java\jdk1.8.0_253.修改 Path%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;4.添加 CLASSPATH%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;5.验证java -versionjavajavac
1.下载linux版1.8JDK包安装版本 jdk-8u191-linux-x64.tar.gz 为例2.解压安装包到指定目录tar -zxvf jdk-8u191-linux-x64.tar.gz3.配置环境变量并生效（1）root用户打开配置文件 /etc/profilevi /etc/profile在末尾添加以下内容：export JAVA_HOME=/home/$USER/programs/soft/jdk1.8.0_381 export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar export PATH=$PATH:${JAVA_HOME}/bin（2）普通用户vi ~/.bash_profile在.bash_profile文件中填入如下语句：export PATH export JAVA_HOME=/home/$USER/programs/soft/jdk1.8.0_381 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar4.使配置文件生效source /etc/profilesource ~/.bash_profile5.检验java环境java -version出现以下内容：java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)