Bootstrap class path not set in conjunction with -source 1.6

I get following warning:


warning: [options] bootstrap class path not set in conjunction with -source 1.6

What does that mean?

I use JDK 7 and have configured the targetCompatibility to 1.6 Gradle Version: 1.5

The warning is issued by the JDK7 Java compiler whenever you compile for an older Java version but against the JDK7 class library. In that case, accidental use of JDK7 only APIs may go unnoticed at compile time. One of the solutions (which the warning is referring to) is to put the JDK6 class library on the compiler’s bootstrap class path.


  1. How to put JDK6 class library on the compiler’s bootstrap class path? 2. Is it necessary? 3. Does it affect how the code is generated?


BTW, I want to run everything in JDK 7. I would like to suppress this warnings and make sure the binaries are generated and optimized for jdk 7.

I have existing code written in the days of JDK 6…

My binaries won’t be run in JDK 6.

If you run Gradle with JDK7 and set ‘sourceCompatibility = 1.7’ (which also sets ‘targetCompatibility = 1.7’), you shouldn’t get any warnings.


Can you explain further about how to suppress this warning if using JDK7 and sourceCompatibility = 1.6?


To get rid of the warning, you need to have JDK 6 installed in any case (or, at the very least, make the JDK 6 class libraries available to everyone), and then it’s much easier to run Gradle with JDK 6 in the first place, rather than pointing the JDK 7 compiler to the JDK 6 class libraries. I haven’t done the latter myself, but I think you’d have to do something like:

tasks.withType(JavaCompile) {
     compileOptions.fork = true
    compileOptions.forkOptions.jvmArgs = [...]

For the exact JVM args to set, see the JDK docs.