今天通过brew安装ant时,安装完之后执行ant -version出现
Error: JAVA_HOME is not defined correctly executing maven
网上查了资料发现是配置环境变量的问题特此记录
Assuming you use bash shell and installed Java with the Oracle installer, you could add the following to your .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/jre/bin:$PATH复制代码
This would pick the correct JAVA_HOME
as defined by the Oracle installer and will set it first in your $PATH
making sure it is found.
Also, you don't need to change it later when updating Java.