Despite specifying JDK 1.7 in all project settings (including in File -> Project Structure -> Project :: Project SDK
), the following error is produced by
One more thing that could cause this is having incorrect version
of the
project.
In my case it was pointing to a non-existing project and for some reason IntelliJ downgraded version in settings to 1.5 and later when I fixed it, it was still interpreting target code version as 5 (despite setting it to 11).