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

mre picture mre · May 21, 2013 · Viewed 25.7k times · Source

Below is the content of the build.gradle file:

apply plugin: 'java'

archivesBaseName    = 'foo-bar'
version             = '1.0'
sourceCompatibility = JavaVersion.VERSION_1_6
targetCompatibility = JavaVersion.VERSION_1_6

sourceSets.main.resources.exclude 'foo.jks'

compileJava{
    println project.sourceCompatibility 
    println project.targetCompatibility 
    println sourceCompatibility 
    println targetCompatibility 
}

And below is the result of running the Gradle jar task:

[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      :jar
[sts] -----------------------------------------------------
1.6
1.6
1.6
1.6
:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6
1 warning

:processResources UP-TO-DATE
:classes
:jar

BUILD SUCCESSFUL

Total time: 1 mins 3.072 secs
[sts] -----------------------------------------------------
[sts] Build finished succesfully!
[sts] Time taken: 1 min, 3 sec
[sts] -----------------------------------------------------

Although it claims that the build was successful, the warning has me a little worried about run-time complications. How do I resolve this warning?

Also, I'm using Eclipse Indigo. And I have the Java compiler and build path of my project set to jdk1.6.0_35.

If anyone needs more information, please let me know!


UPDATE

I navigated to Window > Preferences > Gradle and I set "Java Home" to the "Workspace JRE" jdk1.6.0_35,

enter image description here

And now I get the following output when I run the Gradle jar task,

[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks: 
[sts]      :jar
[sts] -----------------------------------------------------
1.6
1.6
1.6
1.6
:compileJavawarning: java\lang\Enum.class(java\lang:Enum.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Comparable.class(java\lang:Comparable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Object.class(java\lang:Object.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\Serializable.class(java\io:Serializable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\String.class(java\lang:String.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\InputStream.class(java\io:InputStream.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStore.class(java\security:KeyStore.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\Cipher.class(javax\crypto:Cipher.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\spec\SecretKeySpec.class(javax\crypto\spec:SecretKeySpec.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\xml\bind\DatatypeConverter.class(javax\xml\bind:DatatypeConverter.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\CloneNotSupportedException.class(java\lang:CloneNotSupportedException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Class.class(java\lang:Class.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\ClassLoader.class(java\lang:ClassLoader.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStore$LoadStoreParameter.class(java\security:KeyStore$LoadStoreParameter.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\Closeable.class(java\io:Closeable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\AutoCloseable.class(java\lang:AutoCloseable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Exception.class(java\lang:Exception.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Throwable.class(java\lang:Throwable.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\cert\Certificate.class(java\security\cert:Certificate.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\Key.class(java\security:Key.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\spec\KeySpec.class(java\security\spec:KeySpec.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\SecretKey.class(javax\crypto:SecretKey.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\Error.class(java\lang:Error.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyStoreException.class(java\security:KeyStoreException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\GeneralSecurityException.class(java\security:GeneralSecurityException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\RuntimeException.class(java\lang:RuntimeException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\io\IOException.class(java\io:IOException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\NoSuchAlgorithmException.class(java\security:NoSuchAlgorithmException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\cert\CertificateException.class(java\security\cert:CertificateException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\NoSuchPaddingException.class(javax\crypto:NoSuchPaddingException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\InvalidKeyException.class(java\security:InvalidKeyException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\security\KeyException.class(java\security:KeyException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\nio\ByteBuffer.class(java\nio:ByteBuffer.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\IllegalBlockSizeException.class(javax\crypto:IllegalBlockSizeException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: javax\crypto\BadPaddingException.class(javax\crypto:BadPaddingException.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\StringBuilder.class(java\lang:StringBuilder.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\AbstractStringBuilder.class(java\lang:AbstractStringBuilder.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\CharSequence.class(java\lang:CharSequence.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
warning: java\lang\StringBuffer.class(java\lang:StringBuffer.class): major version 51 is newer than 50, the highest major version supported by this compiler.
It is recommended that the compiler be upgraded.
39 warnings

:processResources UP-TO-DATE
:classes
:jar

BUILD SUCCESSFUL

Total time: 1.96 secs
[sts] -----------------------------------------------------
[sts] Build finished succesfully!
[sts] Time taken: 0 min, 1 sec
[sts] -----------------------------------------------------

What do?

Answer

Rudik Krasniynos picture Rudik Krasniynos · Dec 26, 2013

You can bootstrap class path using bootClasspath option:

apply plugin: 'java'

sourceCompatibility = 1.6
targetCompatibility = 1.6

compileJava.options.bootClasspath = "$JDK6_HOME/jre/lib/rt.jar"

To set the bootClasspath option on all compile tasks in the project you can use the withType() method on the TaskContainer to find all tasks of type Compile:

apply plugin: 'java'

sourceCompatibility = 1.6
targetCompatibility = 1.6

tasks.withType(JavaCompile) {
    options.bootstrapClasspath = files("$JDK6_HOME/jre/lib/rt.jar")
}

gradle.properties:

JDK6_HOME=C:/JAVA/jdk6

See documentation for details.