I am trying to edit Java files in VSCode, but am encountering a slew of errors from VSCode. For example:
The type java.lang.Object cannot be resolved.
It is indirectly referenced from required .class files
String cannot be resolved to a type
System cannot be resolved
I tried running Java clean to clean the workspace and have tried reinstalling the Java extension pack. Either way, the problem persisted.
I can't get rid of this and it is really annoying! Please help if you can! Thank you.
There's something wrong with JRE. In some occasions, deleting the Java Language Server workspace directory is helpful to go back to a clean status:
Windows - Delete
%APPDATA%\Code
and%USERPROFILE%\.vscode
.
macOS - Delete$HOME/Library/Application Support/Code
and~/.vscode
.
Linux - Delete$HOME/.config/Code
and~/.vscode
.
If this doesn't work, try to reset jdk and restart vscode:
"java.home": "\path\to\jdk\",
"java.configuration.runtimes":[...]
Reference: Setting for the JDK