Intellij - Unable to use newer Java 8 classes - Error : "Usage of API documented as @since 1.6+.."

Edited the answer based on Bastien Jansen comment.

Seems that there is another project setting that affects the compiler level. A subtle indication of this problem is when your compiler starts complaining of the source and target java version being different from the one you specified while you are compiling the code

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.

To get rid of this, you need to open up

File -> Project Structure -> Project Settings -> Modules -> "Your Module Name" -> Sources -> Language Level

and change that to the desired level i.e 1.8 or the Project Default language level


If you are using maven then Add below line in your configuration pom.xml file and then reimport or build it from maven.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Else select java compiler and Language Level from below path.

File > Project Structure > Project Settings > Modules > your Module name > Sources > Language Level > choose the one which you need.

enter image description here

Change Language level from here :-

enter image description here


Actually, if you are using Maven and your pom.xml project properties are configured correctly

<project xmlns="...> 
....
<properties>
         <maven.compiler.source>1.8</maven.compiler.source>
         <maven.compiler.target>1.8</maven.compiler.target>
</properties>
...
</project

You can reimport Maven parameters to intellij-idea project - right click on project root entry, then Maven -> Reimport which is at the bottom.

picture shows that Maven is second from last item in project right click menu