Check out example codes for "gradle require java version". It will help you in understanding the concepts better.

Code Example 1

// build.gradle
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8

Learn ReactJs, React Native from akashmittal.com