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.
What I did:
1) Add Java Home (point to my JDK) in System environment variables.
2) Add the path (which contain tools.jar) in the Path
system environment variables.
3) Create a dependencies.gradle
files in project folder, to instruct Gradle to look for tools.jar (compile files("${System.properties['java.home']}/../lib/tools.jar")
)
4) Directly put the compile files("${System.properties['java.home']}/../lib/tools.jar")
in the build.gradle dependencies
there.
5) In project preferences there, go Java -> Build Path -> Classpath
Variables, add in JAVA_HOME
variable.
6) Point the project build path to JDK instead of JRE.
None of these is working! What else I could try?
PS: Eclipse version Mars 4.5.2, Gradle version 1.12
build.gradle content (this build script is generated automatically by eclipse):
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'
}
}
}
The Java Home content:
Path environment variable:
C:\Program Files\Java\jdk1.7.0_67\lib
Error showing in eclipse console:
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> 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
(stacktrace too long, I shorten it.)
tools.jar
is inlib
folder, not inbin
folder. – Sam YC