问题描述
我使用的是最新的MacOS catalina(10.15.4),并使用.zshrc
作为我的个人资料的最新版本 mac弃用了bash shell ,这是.
I a using the latest MacOS catalina(10.15.4) and using .zshrc
for my profile as latest version of mac deprecated the bash shell, This is the follow-up question of my previous unanswered question on not able to change the default java version to 1.8 using jenv.
当我尝试调试更多内容时,尽管以下列方式进行了设置,但我的回声$ JAVA_HOME始终返回空白.
When I was trying to debug more found my echo $JAVA_HOME always returns blank, despite having set it in following manner.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
还有
export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
请注意,我已经在更改后获取了我的.zshrc
文件,但是仍然没有运气,尽管当我在终端上进行设置时,它会打印正确的值,但仅在该控制台上(如预期的那样) ).
Note i've sourced my .zshrc
file after the change but still no luck, although when I set on the terminal then it print the proper value but its only on that console(as expected).
添加〜/.zshrc的内容
Adding the content of my ~/.zshrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
#export JAVA11_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
#export JAVA14_HOME=$(/usr/libexec/java_home -v14)
#export RUNTIME_JAVA_HOME=$(/usr/libexec/java_home -v11)
export PATH=$JAVA_HOME/bin:$PATH
#export PATH="/Users/java-dev/Library/Python/3.7/bin/:$PATH"
export PATH=/usr/local/bin:$PATH
export PATH=/usr/bin:$PATH
alias sr='source ~/.zshrc'
alias rt='cd /Users/java-dev/rt'
alias dev='cd /Users/java-dev/development'
alias code='cd /Users/java-dev/code'
推荐答案
查看您的.zshrc
内容,由于您的Jenv
更改了基于目录的Java版本,因此似乎正在发生问题,并且可能已将其弄乱了JAVA_HOME
.
Had a look at your .zshrc
content and looks like issue is happening due to your Jenv
which changed the java versions based on directory and might have messed up your JAVA_HOME
.
您可以尝试删除这些行,然后再试一次.
Can you try removing these line and try again.
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
这篇关于尽管已在zshrc中正确设置了echo $ JAVA_HOME在MacOS catalina中仍返回空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!