Removing warning messages on IntelliJ IDEA while building Java project

Solution 1:

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

Solution 2:

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.

Solution 3:

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

Solution 4:

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

Solution 5:

If you have Maven project, open pom.xml file and add following code inside your project root:

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