Preview features enabled at an invalid source release level 13, preview can be enabled only at source level 14Java(2098258)

Viewed 16963

VS Code is showing anomalous behaviour from into my pc from the last couple of days. I am not able to run a simple java code. At the beginning it's it's giving an error:

> Preview features enabled at an invalid source release level 13, preview can be enabled only at source level 14Java(2098258)

The compilation result ends with: `

Error: Could not find or load main class Lol Caused by: java.lang.ClassNotFoundException: Lol

Lol is the class name in which I have defined the main method.

class Lol
{
  public static void main(String args[])
  {
    System.out.println("write the String");
  }
}

Every time I am stating a new project it's showing me the exact same result and end up giving this error for all the current and previously build java codes.

I have installed jdk14 into my pc and added the path properly to after reading some solution on stackoverflow. But this does not help at all.

Can Anybody tell me where the problem is exactly ???

7 Answers

I had the same issue and what I did: I simply cleaned the Java language server workspace, which can be achieved by doing 3 simple steps:

  1. ctrl + shift + p.

  2. Write to the command palette: Clean the Java language server workspace.

  3. Press enter (restart your VScode).

Visual Studio Code works with all major Java versions from various vendors up to 13.

Source: https://code.visualstudio.com/docs/languages/java (OP date)

Update

The cited passage disappeared (by 05/18/2021), so lets assume, that VSCode now supports java beyond version 13.

Still (the poularity of) this answer, shows that there is some bug, and ... cleaning the java workspace helps!

For me I was getting this error message because of an Eclipse preference file hidden at projectdir\.settings\org.eclipse.jdt.core.prefs. It had the invalid source release level specified under org.eclipse.jdt.core.compiler.source. I changed this and three other locations and instantly VScode started engaging the source code by highlighting things and the build was no longer "failing".

I had the same problem, I clear the java workspace then I restarted the vs code. it works fine now

If the Clean the Java language server won't work for you, try deleting the .project file + .vscode folder under your workspace and restart & delete java server.

I solved this issue by doing the following. press ctrl + shift + p

Write: Clean the Java language server workspace (in latest vscode editions this command is shown as a suggestion)

press enter and restart your vscode.(you will get a prompt asking you to restart. just click)

Once vscode restarts your problems will go away.

I had the same issue and what I did: I simply cleaned the Java language server workspace, which can be achieved by doing 3 simple steps:

ctrl + shift + p.

Write to the command palette: Clean the Java language server workspace.

Press enter (restart your VScode).

Related