Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IDEA: javac: source release 1.7 requires target release 1.7

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

enter image description here

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)

like image 752
James Raitsev Avatar asked Oct 15 '12 16:10

James Raitsev


1 Answers

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

compiler options

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

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

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:

<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> 

or

<project>   [...]   <properties>     <maven.compiler.source>1.8</maven.compiler.source>     <maven.compiler.target>1.8</maven.compiler.target>   </properties>   [...] </project> 

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

reimport

like image 168
CrazyCoder Avatar answered Sep 29 '22 09:09

CrazyCoder