I have a java project with the following directory structure (as required by Gradle\'s \'java\'
plugin, assuming all defaults).
projectRootDir
In my case, the problem was faustinoaq.javac-linter
extension. I uninstall the linter extension and everything works.
To get things right, add the root folder of you project in workspace. To do this in VS Code, go to File -> "Add folder to workspace" and then select the root folder (source folder).
If your files are already in the correct directory, press F1 and type in "Clean the Java Language Server Workspace"
Because vscode
set the src folder
as the default Java Source Path
, you should change it to folder src/main/java
. Just right click the folder src/main/java
in vscode
and click the option Add Folder to Java Source Path
, then reopen the file, and the error is gone.