1.创建.bash_profile
如果是第一次配置环境变量,可以使用"touch .bash_profile" 创建一个 .bash_profile 的隐藏配置文件(如果已经有存在的配置文件,则使用"open -e .bash_profile" 命令)
touch .bash_profile
open -e .bash_profile
2.编辑.bash_profile文件
JAVA_HOME填写自己的Java路径
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
PATH=PATH:.
CLASSPATH=JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
3.使用.bash_profile文件
使配置生效
source .bash_profile
输入 echo $JAVA_HOME 命令显示刚才配置的路
echo $JAVA_HOME
网友评论