简体   繁体   中英

Can't resolve -source errors on IntelliJ with regards to Project Language Level

I am running into errors like these while trying to build my project on IntelliJ on Mac.

Error:(12, 39) java: diamond operator is not supported in -source 1.5
  (use -source 7 or higher to enable diamond operator)

Error:(122, 48) java: method references are not supported in -source 1.5
  (use -source 8 or higher to enable method references)

Error:(124, 51) java: lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)

Looking at other answers on this site, it has to do with Project Language Level being too low. However, mine is set to the following :

项目设置的屏幕截图

Seems like I have the right option selected but I'm still getting the same errors. How do I resolve these issues.

Here is the first part of the log if I used JDK 11.0.1 :

Information:java: JPS build failed to load optimized file manager for javac:
java.lang.NoClassDefFoundError: com/sun/tools/javac/util/DefaultFileManager
java.lang.NoClassDefFoundError: com/sun/tools/javac/file/JavacFileManager
Information:java: Errors occurred while compiling module 'notification-processor'
Information:javac 8 was used to compile java sources
Information:Module "notification-processor" was fully rebuilt due to project configuration/dependencies changes
Information:2018-11-07, 4:38 PM - Compilation completed with 19 errors and 4 warnings in 3 s 490 ms
Warning:java: class org.jetbrains.jps.javac.ast.ExternalRefCollectorCompilerToolExtension : com/sun/source/util/TaskListener
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.

Here is the first part of the logs if I use JDK 8 :

Information:java: Errors occurred while compiling module 'notification-processor'
Information:javac 1.8.0_191 was used to compile java sources
Information:Module "notification-processor" was fully rebuilt due to project configuration/dependencies changes
Information:2018-11-07, 4:39 PM - Compilation completed with 19 errors and 3 warnings in 2 s 858 ms
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.

Please make sure that you do not override language level in module settings:

在此输入图像描述

and compiler settings

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM