Adding to above answers,
if you don't have a multi-module project with different JDKs assigned to each module you can just uncheck this like in below image
Settings -> Java Compiler -> [uncheck] Use compiler from module target JDK when possible
when this option is disabled, IntelliJ IDEA will use the Project JDK to compile all modules, regardless of the JDK assigned to each individual module.