question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'<>' operator is not allowed for source level below 1.7

See original GitHub issue

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.

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:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

12reactions
aaron-junotcommented, Apr 11, 2019

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!

5reactions
fbriconcommented, Jun 7, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found