Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 494
Paul Taylor Avatar asked Oct 05 '12 11:10

Paul Taylor


People also ask

How do I change the default Java version in IntelliJ?

In the Project Structure dialog Ctrl+Alt+Shift+S , select SDKs. Select the necessary JDK version if you have several JDKs configured, and open the Documentation Path tab on the right.

How do I change the source level in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S . Under Project Settings, select Modules | Sources. From the Language level list, select the necessary option. To use the project language level, select Project default.


2 Answers

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.

like image 107
Paul Taylor Avatar answered Sep 19 '22 08:09

Paul Taylor


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.

like image 34
Gyuri Majercsik Avatar answered Sep 19 '22 08:09

Gyuri Majercsik