title: ./gradlew The operation couldn’t be completed. Unable to locate a Java Runtime
body: <p>When I run <code>./gradlew</code> from project folder I get:</p>
  <pre><code>./gradlew
  The operation couldn’t be completed. Unable to locate a Java Runtime.
  Please visit http://www.java.com for information on installing Java.
  </code></pre>
  <p>The same with java:</p>
  <pre><code>which java
  /usr/bin/java
  
  /usr/bin/java
  The operation couldn’t be completed. Unable to locate a Java Runtime.
  Please visit http://www.java.com for information on installing Java.
  </code></pre>
  <p>I installed JDK in Android studio, seems it's installed in <code>~/Library/Android/sdk/sources/android-28</code></p>
  <p>Setting <code>export JAVA_HOME=/Users/mrgloom/Library/Android/sdk/sources/android-28/</code> or <code>export JAVA_HOME=/Users/mrgloom/Library/Android/sdk</code> produce error like:</p>
  <pre><code>ERROR: JAVA_HOME is set to an invalid directory: /Users/mrgloom/Library/Android/sdk/sources/android-28/
  
  Please set the JAVA_HOME variable in your environment to match the
  location of your Java installation.
  </code></pre>
  <p>How to specify java path for <code>gradlew</code> ?</p>