If you issue gradle -version it will tell you the JVM it has picked up. Just to be certain, could you please run the command please and see what version its reporting? Here’s the output when I run on mine (most of my builds are against Java 8 and run fine)
------------------------------------------------------------ Gradle 2.1 ------------------------------------------------------------ Build time: 2014-09-08 10:40:39 UTC Build number: none Revision: e6cf70745ac11fa943e19294d19a2c527a669a53 Groovy: 2.3.6 Ant: Apache Ant™ version 1.9.3 compiled on December 23 2013 JVM: 1.8.0_20 (Oracle Corporation 25.20-b23) OS: Mac OS X 10.9.4 x86_64
Ok that looks fine. I notice the only difference to mine is that you are running Yosemite. However, before investigating that path, how are you defining the sourceCompatibility 1.8 string in your build?
In versions of Gradle < 2, it used to be able to pick it up declared directly as vars in the build script. Eg just on its own not in a compileJava block:
sourceCompatibility = ‘1.8’
Cheers Kon
Edit Noticed the formatting came out wrong when viewed on the webpage
Something in your build environment is overriding your java home.
There are a few places this can happen. For example, IntelliJ will pick up the version the JDK you have set in your Project properties if you haven’t explicitly configured it. If you haven’t configured this it’ll default to some other JDK (in my case the JDK intellij itself is running on Java 6 and fail with the same message)
Firstly, does gradle --version still report Java 8, but the System.getProperty(“java.home”) reports path to Java 7? Also what is the output of /usr/libexec/java_home -t CommandLine?
Do you have anything in a ~/gradle.properties file set?
In the meantime you can specify a property in your command line to point Gradle to the right java.home to use. For example