title: Intellij Gradle terminal ERROR: JAVA_HOME is not set
body: <p>In IntelliJ IDEA, using the Gradle window I am able to execute any and all Gradle tasks. However, when I try and execute the same tasks through the terminal window within the IDE, it hits me with the following error:</p>
  
  <pre><code>ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  
  Please set the JAVA_HOME variable in your environment to match the
  location of your Java installation.
  </code></pre>
  
  <p>This occurs when using gradle and gradlew. In IntelliJ -> File -> Project Structure -> Project then SDK is set correctly to 1.8. Any suggestions for resolving this so I can use the terminal to execute Gradle tasks would be greatly appreciated.</p>