Check if / usr / libexec / java _home exists. If this happens, try running
export JAVA_HOME=`/usr/libexec/java_home`
and try to build gradlew again. If it works, make it permanent with
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
source share