Building of a Gradle project yields the following warning:

:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning

That happens whenever the project is compiled to be compatible with an older Java version compared to the installed JDK (Java 8 in my case).

build.gradle
apply plugin: 'java'
sourceCompatibility = 1.7
...

The warning indicates that Gradle has no access to the legacy JDK (1.7). The issue is in fact with the Java compiler. According to the javac docs you are supposed to provide path to the bootstrap classes rt.jar.

You can easily verify the issue is not with Gradle. Let’s pick any of your source files and try to compile them.

Check the installed JDK

$ java -version java version "1.8.0_51" Java(TM) SE Runtime Environment (build 1.8.0_51-b16) Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

Compile the source code with default settings

$ javac src/main/java/Library.java

No warnings, all is good. Now specify the -source flag, which is equivalent to the souceCompatibility property in your build file.

$ javac -source 1.7 src/main/java/Library.java warning: [options] bootstrap class path not set in conjunction with -source 1.7 1 warning

See? You get the same warning you were getting when running gradle build. Now add the -target flag, which maps to targetCompatibility in Gradle’s Java plugin.

$ javac -source 1.7 -target 1.7 src/main/java/Library.java warning: [options] bootstrap class path not set in conjunction with -source 1.7

That change had no effect, because … let me quote the javac docs:

You must specify the -bootclasspath option to specify the correct version of the bootstrap classes (the rt.jar library). If not, then the compiler generates a warning:

javac -source 1.7 OldCode.java
warning: [options] bootstrap class path not set in conjunction with -source 1.7


Tomas Zezula

Hello! I'm a technology enthusiast with a knack for solving problems and a passion for making complex concepts accessible. My journey spans across software development, project management, and technical writing. I specialise in transforming rough sketches of ideas to fully launched products, all the while breaking down complex processes into understandable language. I believe a well-designed software development process is key to driving business growth. My focus as a leader and technical writer aims to bridge the tech-business divide, ensuring that intricate concepts are available and understandable to all. As a consultant, I'm eager to bring my versatile skills and extensive experience to help businesses navigate their software integration needs. Whether you're seeking bespoke software solutions, well-coordinated product launches, or easily digestible tech content, I'm here to make it happen. Ready to turn your vision into reality? Let's connect and explore the possibilities together.