I'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.
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.
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.
Was facing the same issue. The linter will whine for using any language feature above version 1.5(lambdas, try-with-resources).
Changing the Maven source, target works. Thanks @fbricon
Okay. That’s the issue then.
I’ll fix my maven file and then it should work.
Sorry for that.
Best
Roman
On 6 Jul 2018, at 05:14, Siddharth Shishulkar notifications@github.com wrote:
Was facing the same issue. The linter will whine for using any language feature above version 1.5.
Changing the Maven source, target works. Thanks @fbricon—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
The suggested solution was to correct the Maven project settings, but the problem occurs even when there is no problem there (the project builds from the command-line).
It seems like this may be an issue in 'Microsoft/vscode-maven'
In case anybody runs into this issue like I did today, I fixed this by adding a <properties> tag to my pom.xml:
<project>
[...]
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
[...]
</project>
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!
In case anybody runs into this issue like I did today, I fixed this by adding a
<properties>tag to mypom.xml:<project> [...] <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> [...] </project>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!
Thank you. This resolves my problem!
Most helpful comment
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!