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?
libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux, macOS, Android, your browser and iOS.
Eclipse: Select all your projects in the package explorer, right click, then click Gradle -> Refresh All . This will download the libGDX version you specified in build. gradle and wire up the JAR files with your projects correctly.
If you're using IntelliJIDEA, make 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With