Using Java 8 with LibGDX

I am writing a game in Java using LibGDX only desktop

as a target framework. I just created a new LibGDX project and imported some existing code into it, but now I am getting a few errors. In particular, using diamond operator

. For example, this line of code:

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

      

generates 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 would like to use Java 8. The Gradle files in the imported module were saved, so I changed the line sourceCompatibility

in all other files build.gradle

throughout the project from 1.6

to 1.8

and I made sure Project Structure > Project > Language Level

Java 8 was installed in. However, I still get this problem. What else do I need to change for my project to use Java 8?

+3


source to share


1 answer


If you are using IntelliJIDEA, make your changes in three places.



  • sourceCompatibility = 1.8

    in build.gradle file of all modules

  • Project Structure > Project > Language Level

  • Project Structure > Modules > Sources Tab on all modules > Language Level

+5


source







All Articles