# Gradle uses java6 compiler even with source compatability 1.7

**URL:** <https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078>\
**Category:** Old Forum Archive\
**Created:** [May 27, 2014, 9:25am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078 "2014-05-27T09:25:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sangeetha\_Karthik](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sangeetha\_Karthik](https://discuss.gradle.org/u/Sangeetha_Karthik)\
**Post date:** [May 27, 2014, 9:25am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/1 "2014-05-27T09:25:00Z")

</div>

Hi,

We are using gradle 1.12 for our java build. The problem is that in a particular machine, the build breaks, since gradle _seems_ to use the java 6 compiler. The logs are shown below:

Gist link of the build failure: [https://gist.github.com/anonymous/62c99d6f87b398a58f66](https://gist.github.com/anonymous/62c99d6f87b398a58f66)

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 27, 2014, 9:41am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/2 "2014-05-27T09:41:00Z")

</div>

By default, Gradle will compile with the same JDK that Gradle itself is run with, so perhaps that machine has JDK6 on its ‘PATH’, or has ‘JAVA\_HOME’ pointing to JDK6. ‘gradle -v’ will tell.

PS: ‘jdk6.Jdk6JavaCompiler’ in the stack trace doesn’t mean that Gradle is compiling with JDK6. It just means that it is using the compiler API _introduced_ in JDK6.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 27, 2014, 12:35pm UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/3 "2014-05-27T12:35:00Z")

</div>

I should add that ‘sourceCompatibility’ doesn’t have any effect on which compiler/runtime library will be used. It just determines the language level used by the compiler.

---

<div class="post-metadata">

**Author:** ![Sangeetha\_Karthik](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sangeetha\_Karthik](https://discuss.gradle.org/u/Sangeetha_Karthik)\
**Post date:** [May 28, 2014, 6:43am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/4 "2014-05-28T06:43:00Z")

</div>

Thank you for the quick response. However, when we do print out the version of the JVM on the command prompt and JAVA\_HOME, it all points to JDK 7. Furthermore, JDK 6 is not even installed in the system. See below Gist: [https://gist.github.com/anonymous/0aa9d69431ebfb7415d8](https://gist.github.com/anonymous/0aa9d69431ebfb7415d8)

We’re pretty sure that whatever logs we have would not be sufficient to figure out the cause, but we appreciate the help nevertheless. In any case, is there a way that we can print out on the console the actual java command run by the build - that might throw up some pointers as to where the issue lies.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 28, 2014, 6:52am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/5 "2014-05-28T06:52:00Z")

</div>

What counts is the Java version printed by ‘gradle -v’. If this prints “1.7.0” under “JVM”, then unless you’ve reconfigured ‘compileJava.options.forkOptions.executable’, JDK7 will be used for compilation. (If you’ve set ‘compileJava.options.fork = true’ or ‘compileJava.options.useAnt = true’, try to set both to ‘false’.) Running with ‘–info’ should print out the equivalent ‘javac’ command, however what’s really used is the Java compiler _API_.

---

<div class="post-metadata">

**Author:** ![Sangeetha\_Karthik](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Sangeetha\_Karthik](https://discuss.gradle.org/u/Sangeetha_Karthik)\
**Post date:** [May 29, 2014, 2:14am UTC](https://discuss.gradle.org/t/gradle-uses-java6-compiler-even-with-source-compatability-1-7/2078/6 "2014-05-29T02:14:00Z")

</div>

Thank you - that should be fine to try and get to the root cause.
