码迷,mamicode.com
首页 > 编程语言 > 详细

【JAVA】mac配置java环境变量

时间:2018-06-14 18:29:30      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:not   文件   exec   let   打开   comm   nes   环境变量   for   

如果用bash,修改~/.bash_profile 或 ~/.profile;

如果用zsh,修改~/.zshrc

修改这些文件之后,重修打开terminal,配置不会丢 

首先确保已经安装了jdk:

## check the present running java
which java

## check java version
java -version

以zsh为例:
## check all the available jdk
 2 /usr/libexec/java_home -V
 3 
 4 ## check the top jdk
 5 /usr/libexec/java_home
 6 
 7 ## check some jdk (eg. version 1.7)
 8 /usr/libexec/java_home -v 1.7
 9 
10 ## edit .zshrc to set java_home variable
11 vim ~/.zshrc
12 
13 ## add the following line into the file
14 export JAVA_HOME=$(/usr/libexec/java_home)
15 
16 ## you can also use the following line to set the variable, which is not recommended, only for older mac os.
17 ## export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
18 
19 ##let the configuration in .zshrc take effect
20 source ~/.zshrc
21 
22 ## check if configure succeed
23 echo $JAVA_HOME

【JAVA】mac配置java环境变量

标签:not   文件   exec   let   打开   comm   nes   环境变量   for   

原文地址:https://www.cnblogs.com/zengweiming/p/9183259.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!