Removing warning messages on IntelliJ IDEA while building Java project

Check java version in your pom.xml(here you can find how to do it). Also check java version in Project Structure. And the last what you can do - check compiler version e.g.

enter image description here


In my case none of the above solution worked. But changing language level in project structure did.

File -> Project Structure -> Project Settings -> Modules -> under "sources" tab change language level to some upper version.

enter image description here


If the project with Maven, check pom.xml file for source and target:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.6.1</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>${project.build.sourceEncoding}</encoding>
      </configuration>
    </plugin>
  </plugins>
</build>

And in case of Gradle - check build.gradle for:

plugins {
    id 'java'
}
sourceCompatibility = 1.8

I did all of the above and still had one instance of the warning:

Warning:java: source value 1.5 is obsolete and will be removed in a future release

I went into my project_name.iml file and replaced the following tag:

<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">

with:

<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">

And voila, no more error message. Hope this helps someone.