1

Hi I'm trying to run a simple Java program that uses method references, but IntelliJ keeps saying:

method references are not supported in -source 1.7 (use -source 8 or higher to enable method references): 31

However, when I open my project settings the ProjectSDK is set to 1.8 and the Project language level is set to 8

When I click on Modules the Language level is set to 8

and if I look under Preferences > Build, Execution, Deployment > Build Tools > Gradle

and look at the Gradle JVM it says it is the same as the Project SDK which is 1.8.

Also if I look under Preferences > Build, Execution, Deployment > Compiler > Java Compiler

like suggest here I get 8 which is correct.

So why is it giving me that error message? I don't believe there is anything 1.7 in my project.

mpdunson
  • 227
  • 1
  • 11

1 Answers1

1

what about your "sourceCompatibility" and "targetCompatibility" in your gradle-file?

can you try to put these properties to:

def javaVersion = JavaVersion.VERSION_1_8;
sourceCompatibility=javaVersion;
targetCompatibility=javaVersion;
  • Thank you so much. You're right my sourceCompatibility was set to 1.7 in my build.gradle. I opened someone else's project because I was following a tutorial on generics and I didn't bother to check my build.gradle file since I don't know much about gradle. – mpdunson Feb 24 '21 at 18:36