Unable to compile using Java 1.7 in Jetbrains Intellij after moving from 1.6 to 1.7 (maven based project)

45,297

Solution 1

Doh, found it

File/Settings/Java Compiler/Additional command line parameters

changed from -target 1.6 to -target 1.7

Does seem wierd for it to be here though, disconnected from the rest of the related options.

Solution 2

As an alternative solution, which worked for me is to check in Module Settings the Language Level property. It was set to 8.0 Lambdas and changed to 6.0 @Overrides in interfaces, and after that compilation worked without error.

Solution 3

IntelliJ 2017 (also 15 or 2016)

You can change compiler version here:

File -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler

Now change Target bytecode version to desired one.

IntelliJ 13 or 14

You can change compiler version here:

 Intellij IDEA -> Preferences -> Compiler -> Java Compiler
 -> Project bytecode version -> 1.7 (for example)

Solution 4

For IntelliJ 12, I solved this by opening the File:Project Structure and updating the Project SDK to 1.7 and the Project language level to "7.0 - Diamonds, ARM, multi-catch etc."

If you don't have IntelliJ configured with JDK 1.7, add it with the "New" button. Select type "JDK".

Solution 5

Another potential fix is to make sure that your build file has the version hardcoded as seen here

    <javac target="1.7" source="1.7" ... />

as opposed to

<property name="java.version" value="1.7" />
<javac target="${java.version}" source="${java.version}" ... />

Though this could be due to my misunderstanding of how variables work in build files. You would think that this would make sense though

Share:
45,297
Paul Taylor
Author by

Paul Taylor

Runs Albunack providing awesome artist discographies and the Jaikoz and SongKong Music Tagger applications. Main skills:Java and Databases. Also, photographer concentrating on the less obvious in South-West England, photographs can be seen at Secret Dorset Photo

Updated on July 09, 2022

Comments

  • Paul Taylor
    Paul Taylor almost 2 years

    Using Jetbrains 11.2 project based on a Maven project. Then I required to move to 1.7. I have 1.7 installed , I updated my pom.xml and I can rebuild the whole package using maven okay.

    I've modified every setting I can see in Intelli Projects settings regarding Java version

    • Project SDk
    • Project language Level
    • Modules Languages/Sources/Language Level
    • Modules Languages/Dependencies/Module SDK

    but I cannot get it to compile a file it complains:

    Error:javac target release of 1.6 conflicts with source release 1.7
    

    I then tried on my other dev machine using the same codebase but a different Intellij Project and on this I get a similar error:

    Error:javac: source release 1.7 requires target release 1.7
    

    I cannot see anything else to change in order to get this working.