I tried running ./gradlew
from an Android project directory, but I get an error of:
ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
Navigated to /Library/Java/JavaVirtualMachines
. jdk1.8.0_11.jdk
exists, but so does jdk1.7.0_79.jdk
which java
prints out /usr/bin/java
printenv
prints
...
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home JDK_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
...
javac -version
prints javac 1.8.0_11
which javac
prints /usr/bin/javac
To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.
The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed in your system. You can specify the path according to the location where Java is installed in your system. For MAC OSX it is: /Library/Java/Home.
In macOS, the JDK installation path is /Library/Java/JavaVirtualMachines/jdk-10. jdk/Contents/Home . The root directory of the JDK software installation.
Check if /usr/libexec/java_home exists. If it does then try running
export JAVA_HOME=`/usr/libexec/java_home`
and rerunning your gradlew build. If it works then make it permanent with
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With