Though I tried much of the above, I could only sovle the problem by simply renaming the Java project directory in Windows File Explorer. Then I opened the newly named directory in VS Code and everything worked fine.