我的JAVA_HOME值无效并且我无法更改它

问题描述 投票:0回答:1

我目前正在开发一个反应本机项目,在尝试运行时遇到此错误

yarn android

ERROR: JAVA_HOME is set to an invalid directory: /Users/olamidembp/.jenv/versions/system

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

以下是一些有助于调试的详细信息。 当我运行

javac -version
时,我得到这个输出
javac 17.0.9

这就是我的内容

~/.zshrc

export PATH=/opt/homebrew/bin:$PATH

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init - zsh)"

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
export JAVA_HOME="/Applications/Android Studio.app/Contents/jre/Contents/Home"

我尝试使用不同的方法将

JAVA_HOME
设置为多个值,但它没有改变。

我希望能够使用我已安装的 Java 17 来运行

yarn android

java android react-native
1个回答
0
投票

您可以通过运行以下命令来检查 Java 的安装位置:

/usr/libexec/java_home -v 17
© www.soinside.com 2019 - 2024. All rights reserved.