HiveBrain v1.2.0
Get Started
← Back to all entries
patternjavaCritical

IDEA: javac: source release 1.7 requires target release 1.7

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
sourcerequiresreleasetargetideajavac

Problem

When running a JUnit test, using IntelliJ IDEA, I get

How can I correct this?

  • Using SDK 1.7



  • Module language level is 1.7



Maven build works fine. (That's why I believe this in IDEA configuration issue)

Solution

Most likely you have incorrect compiler options imported from Maven here:

Also check project and module bytecode (target) version settings outlined on the screenshot.

Other places where the source language level is configured:

  • Project Structure | Project



  • Project Structure | Modules (check every module) | Sources



Maven default language level is 1.5 (5.0), you will see this version as the Module language level on the screenshot above.

This can be changed using maven-compiler-plugin configuration inside pom.xml:


  [...]
  
    [...]
    
      
        org.apache.maven.plugins
        maven-compiler-plugin
        
          1.8
          1.8
        
      
    
    [...]
  
  [...]


or


  [...]
  
    1.8
    1.8
  
  [...]


IntelliJ IDEA will respect this setting after you Reimport the Maven project in the Maven Projects tool window:

Code Snippets

<project>
  [...]
  <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>
  [...]
</project>
<project>
  [...]
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  [...]
</project>

Context

Stack Overflow Q#12900373, score: 791

Revisions (0)

No revisions yet.