1.查看java
$ which java
2. 查看JAVA_HOME
$ echo $JAVA_HOME
3. 查看java 路径
$ /usr/libexec/java_home -V
输出:
1.8.0_121 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
4.设置 JAVA_HOME
- 编辑.bash_profile文件:vim ~/.bash_profile
- 添加
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
3.使修改的文件生效:source ~/.bash_profile