'<>' operator is not allowed for source level below 1.7
See original GitHub issueI’m getting the error: ‘<>’ operator is not allowed for source level below 1.7 in VSCode on a code line like this:
List<Integer> v0 = new ArrayList<>();
The interesting part is that I do not have any JDK installed lower than 1.8.
I am wondering how I could configure the compiler with which option to recognize source as 1.8 and target as 1.8.
Environment
- Operating System: MacOS High Sierra 10.13.4
- JDK version: 1.8.0_172
- Visual Studio Code version: 1.23.1
- Java extension version: 0.3.0
Steps To Reproduce
Java environment is identified though JAVA_HOME environment variable pointing to: /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/ Any <> operator causes this error in compilation in my setup.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
openjdk 1.7 in eclipse: operator is not allowed for source level ...
Right-click on the project. Choose Properties. Choose Java Compiler on the left. Choose 1.7 for the Compiler Compliance level. If the 2 drop-downs...
Read more >operator is not allowed for source level below 1.7 - Testing AMA
1 Answer ... From left hand side, click Java Compiler. Make sure that "Enable project specific settings" is checked. Select "Compiler compliance level"...
Read more >How to fix '<>'operator is not allowed for source level 1.7-eclipse
Open project in eclipse; Right click on Project and go to Properties; In Properties panel: click "Java Compiler" at the left and update...
Read more >(SOLVED) [ERROR] '<>' operator is not allowed for source ...
Hi guys,. I'm in desperate need for some assistance here. I am new to java, eclipse and maven so this may be a...
Read more >EMF » Problem Reloading Genmodel. `<>` operator is not ...
The error says that there was a problem while parsing a Java file. The problem being that the `<>` operator is not allowed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In case anybody runs into this issue like I did today, I fixed this by adding a
<properties>
tag to mypom.xml
:Source: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
Thanks everyone in this thread, it was very helpful!
Do you see that in a Maven, Gradle or Eclipse project? or a standalone file? Please note for Maven projects, you need to set the compiler configuration source and target to 1.8, as the default is set to 1.5.