Use -source 8 or higher to enable default methods

hi, trying to move a project to java 8. my build.gradle has:

targetCompatibility = “1.8”

sourceCompatibility = “1.8”

in it. but the build fails.

what is the correct way to specify java 8?

thanks

build file:

task wrapper(type: Wrapper) { gradleVersion=‘2.3’ } repositories { mavenCentral() } apply plugin: ‘java’ targetCompatibility = “1.8”

sourceCompatibility = “1.8” jar {

manifest {

attributes ‘Main-Class’: ‘gui.Main’

} } apply plugin: ‘application’ mainClassName = ‘gui.Main’ // for application plugin mainClassName = ‘controller.CommandLine’ // for application plugin //apply plugin: ‘checkstyle’ //apply plugin ‘project-report’ version = ‘0.1’ // for what? sourceSets.main.java.srcDirs = [“src”] sourceSets.test.java.srcDirs = [“tst”] sourceSets.main.resources.srcDirs = [“resources”] sourceCompatibility = 1.6 dependencies {

compile fileTree(dir: ‘lib’, includes: [’*.jar’])

testCompile group: ‘junit’,name:‘junit’,version: ‘4.8+’ }

output:

D:\ray\dev\goapps\go3>gradle run :compileJava warning: [options] bootstrap class path not set in conjunction with -source 1.6 D:\ray\dev\goapps\go3\src\controller\CommandLine.java:118: error: diamond operat or is not supported in -source 1.6

List frames=new LinkedList<>();

^

(use -source 7 or higher to enable diamond operator) D:\ray\dev\goapps\go3\src\equipment8\Board.java:9: error: default methods are no t supported in -source 1.6

default boolean hasHoles() {

^

(use -source 8 or higher to enable default methods) D:\ray\dev\goapps\go3\src\equipment8\Board.java:72: error: static interface meth ods are not supported in -source 1.6

static List neighbor4s(Point point) {

^

(use -source 8 or higher to enable static interface methods) D:\ray\dev\goapps\go3\src\equipment8\Board.java:73: error: diamond operator is n ot supported in -source 1.6

ArrayList neighbors=new ArrayList<>(4);

^

(use -source 7 or higher to enable diamond operator) 4 errors 1 warning :compileJava FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:compileJava’. > Compilation failed; see the compiler error output for details.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.824 secs

D:\ray\dev\goapps\go3>

oops, i have a: sourceCompatibility = 1.6 in there :frowning:

and that was the problem.

thanks