尽管已在zshrc中正确设置了echo $ JAVA_HOME在MacOS catalina中仍返回空白 [英] echo $JAVA_HOME returns blank in MacOS catalina despite having set it properly in zshrc

查看:609
本文介绍了尽管已在zshrc中正确设置了echo $ JAVA_HOME在MacOS catalina中仍返回空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新的MacOS catalina(10.15.4),并使用.zshrc作为我的个人资料的最新版本我先前无法解决的问题,无法更改默认Java版本使用jenv达到1.8 .

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中仍返回空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆