0

After importing into IntelliJ 2017.1 RC a simple Maven project created with the Quickstart archetype, I get compiler errors because IntelliJ insists on compiling as Java 1.5 code.

  • I have only a Java 8 Update 121 JDK installed on my Mac (macOS Sierra).

enter image description here

  • I verified that File > Project Structure > Project > Project SDK is set to 1.8 (java version "1.8.0_121").
  • I verified that File > Project Structure > Project > Project language level is set to 8 - Lambdas, type annotations etc..

screenshot of IntelliJ Preferences > Build, Execution, Deployment > Compiler > Java Compiler panel

  • I changed Preferences > Build, Execution, Deployment > Compiler > Java Compiler > Project bytecode version to 1.8 from blank.
  • I changed Preferences > Build, Execution, Deployment > Compiler > Java Compiler > Per-module bytecode version to 1.8 from 1.5 in my single list item (named with my package name).

And…

  • I chose menu item Build > Build Project.
  • I chose menu item Build > Recompile.
  • I chose menu item Build > Rebuild Project.

Yet I continue to get error messages related to misinterpreting Java 8 code as Java 5 code, such as:

Error:(28, 113) java: underscores in literals are not supported in -source 1.5

(use -source 7 or higher to enable underscores in literals)

What else must I do to convince IntelliJ that my code should be compiled as Java 8 code rather than as Java 5 code?

Community
  • 1
  • 1
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • You have changed the `target` version, `source` version is configured elsewhere, see [this answer](http://stackoverflow.com/a/12900859/104891). – CrazyCoder Mar 20 '17 at 06:01
  • Yes, that fixed it: Change `File` > `Project Structure` > `Project settings` > `Modules` > `Sources` (tab) > `Language Level` from `5.0 'enum' keyword, generics, autoboxing, etc.` to `8 - Lambdas, type annotations etc.` – Basil Bourque Mar 20 '17 at 06:08
  • As a prophylactic, add these 4 lines to your POM before importing into IntelliJ: ` 1.8 1.8 ` per [this Maven page](https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html). – Basil Bourque Mar 20 '17 at 06:30

0 Answers0