I am running a build task in a java project in Visual Studio Code. The warning in the "PROBLEMS" tab:
[myfile].java is a non-project file, only
Try cleaning the Java language server workspace:
Just worked for me.