title: Eclipse Gradle build "Could not find tools.jar"
body: <p>I have googled for whole day, and tried almost all the suggested solutions, none is working for my eclipse, totally have no idea what went wrong, it kept saying "Could not find tools.jar" when I try to build via Gradle.</p>
  
  <p>What I did:</p>
  
  <p>1) Add Java Home (point to my JDK) in System environment variables.</p>
  
  <p>2) Add the path (which contain tools.jar) in the <code>Path</code> system environment variables.</p>
  
  <p>3) Create a <code>dependencies.gradle</code> files in project folder, to instruct Gradle to look for tools.jar (<code>compile files("${System.properties['java.home']}/../lib/tools.jar")</code>)</p>
  
  <p>4) Directly put the <code>compile files("${System.properties['java.home']}/../lib/tools.jar")</code> in the <code>build.gradle dependencies</code> there.</p>
  
  <p>5) In project preferences there, go <code>Java -&gt; Build Path -&gt; Classpath</code> Variables, add in <code>JAVA_HOME</code> variable.</p>
  
  <p>6) Point the project build path to JDK instead of JRE.</p>
  
  <p>None of these is working! What else I could try? </p>
  
  <p>PS: Eclipse version Mars 4.5.2, Gradle version 1.12</p>
  
  <p>build.gradle content (this build script is generated automatically by eclipse):</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'eclipse'
  
  sourceCompatibility = 1.5
  version = '1.0'
  jar {
      manifest {
          attributes 'Implementation-Title': 'Gradle Quickstart',
                     'Implementation-Version': version
      }
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
      testCompile group: 'junit', name: 'junit', version: '4.+'
  }
  
  test {
      systemProperties 'property': 'value'
  }
  
  uploadArchives {
      repositories {
         flatDir {
             dirs 'repos'
         }
      }
  }
  </code></pre>
  
  <p>The Java Home content:</p>
  
  <p><a href="https://i.stack.imgur.com/2VwfE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2VwfE.png" alt="enter image description here"></a></p>
  
  <p>Path environment variable:</p>
  
  <p><code>C:\Program Files\Java\jdk1.7.0_67\lib</code></p>
  
  <p>Error showing in eclipse console:</p>
  
  <pre><code>:compileJava FAILED
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':compileJava'.
  &gt; Could not find tools.jar
  
  * Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 0.152 secs
  [sts] Build failed
  org.gradle.tooling.BuildException: Could not execute build using Gradle 
  installation 'C:\buildtools\gradle-2.12'.
  Caused by: java.lang.IllegalStateException: Could not find tools.jar
  </code></pre>
  
  <p>(stacktrace too long, I shorten it.)</p>