7

I'm writing a game in Java using LibGDX, with only desktop as the targeted platform. I just created a new LibGDX project, and imported some existing code into it, but now I'm getting a few errors. Specifically, using the diamond operator. For example, this line of code:

HashMap<String, Integer> connectionsMap = new HashMap<>();

is generating this error:

Error:(20, 37) java: diamond operator is not supported in -source 1.6
(use -source 7 or higher to enable diamond operator)

Ideally, I'd like to use Java 8. The Gradle files in the module I imported were preserved, so I changed the sourceCompatibility line in all the other build.gradle files throughout the project from 1.6 to 1.8, and I made sure that in the Project Structure > Project > Language Level was set to Java 8. However, I'm still getting this issue. What else do I need to change for my project to use Java 8?

Thomas
  • 1,123
  • 3
  • 13
  • 36
  • It depends what IDE you're using, you need to compile with Java 8. – Jacob G. May 01 '17 at 15:48
  • @JacobG. I'm using Intellij, I made sure the `Project Structure > Project > Language Level` was set to Java 8 and the run configuration was set to use Java 8 – Thomas May 01 '17 at 16:31

1 Answers1

10

If you're using IntelliJIDEA, make changes in three places.

  1. sourceCompatibility = 1.8 in build.gradle file of all modules

  2. Project Structure > Project > Language Level

  3. Project Structure > Modules > Sources Tab on all modules > Language Level

Abhishek Aryan
  • 19,936
  • 8
  • 46
  • 65