终端输入mvn -version报错:
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
Java环境变量的问题,打开bash_profile查看open ~/.bash_profile
文章来源:https://www.toymoban.com/news/detail-798056.html
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_361.jdk/Contents/Home
alias jdk8='export JAVA_HOME=$JAVA_8_HOME'
#java17
export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
alias jdk17='export JAVA_HOME=$JAVA_17_HOME'
JAVA_HOME=$JAVA_8_HOME
export PATH=$PATH:/usr/local/mysql/bin
export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"
# export PATH=${PATH}:/Users/gorwaywong/Library/Python/3.9/bin
export PATH="/Users/gorwaywong/anaconda3/bin:$PATH"
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/gorwaywong/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/gorwaywong/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/gorwaywong/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/gorwaywong/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
export PATH="/opt/homebrew/bin:$PATH"
发现Java8和Java17版本的环境变量都有,而且默认是Java8
终端中输入:jdk17
查看版本成功.文章来源地址https://www.toymoban.com/news/detail-798056.html
到了这里,关于mac查看maven版本报错:The JAVA_HOME environment variable is not defined correctly的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!