24

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.

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351

6 Answers6

38

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.

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
13

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.

Gyuri Majercsik
  • 2,141
  • 1
  • 17
  • 29
9

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)
Community
  • 1
  • 1
kiedysktos
  • 3,910
  • 7
  • 31
  • 40
  • Similar problem here : http://stackoverflow.com/questions/12900373/idea-javac-source-release-1-7-requires-target-release-1-7 – Benj Jun 09 '16 at 08:01
7

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

Heather92065
  • 7,333
  • 6
  • 31
  • 39
1

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

Merlin -they-them-
  • 2,731
  • 3
  • 22
  • 39
1

I encountered the same problem. I solved it by Intellij IDEA -> Preferences -> Compiler -> Java Compiler -> Project bytecode version -> 1.7 & Target bytecode version -> 1.7

Yan
  • 11
  • 2