Asked  2 Months ago    Answers:  5   Viewed   489 times

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 syntax errors are reported

It refers to the first line where I load in the class file containing the main():

package [the project folder];
import [the project folder].[the file with other classes].*;
  • I can only avoid the warning by copying the files' text (the code text itself) into new java files of a new project in a new unrelated folder. The code itself is correct and compiles without errors. Actually, this is the answer, but it is much manual work.
  • When I just copy the java files of the project with the warning message into a new folder, the warning still appears!!!! (!)
  • When I just copy the whole project folder to a new place, the error remains as well, of course.

I guess that copying text into new java files with the same names and the same folder structure is different from copying the files themselves because the files probably get tagged by VS Code, so that they have a project stamp even when the folder structure is destroyed. Perhaps this supports recovering the project structure from recovered raw files? Could this be the problem of this Visual Code warning?

I checked other threads before, this is just the last step.

  • How can I fix build failed, do you want to continue? in vscode
  • Visual Studio Code - Java - Import Errors and More

--> Thus, I cleaned vscode's workspaceStorage (on Windows: C:UsersUSERAppDataRoamingCodeUserworkspaceStorage) and restarted without success.



I got the same warning simply because I had two Java (Maven) projects in the same vscode workspace. Once I moved projectA out of the workspace, the warning for projectB is gone.

│   projectA

My current solution is to have one Java (Maven) project for one workspace, i.e, one Maven project per vscode workspace.

My guess is that vscode treats all Java projects inside the same workspace as as one project and hence, the projects interfering with each other.

Thursday, August 12, 2021
Mawg says reinstate Monica
answered 2 Months ago

1.Compile the .java file, which generates the .class file:


2.Create .jar:

jar cvfe DoTheFunny.jar DoTheFunny .

3.Run the .jar by command or double-click it in the folder:

java -jar DoTheFunny.jar

enter image description here

Thursday, September 2, 2021
answered 2 Months ago

Either use setup.cfg for single project or change your user settings for all py files.

    "python.linting.pycodestyleEnabled": true,
    "python.linting.pycodestyleArgs": [

Before October 2019 all pycodestyle settings were named pep8:

    "python.linting.pep8Enabled": true,
    "python.linting.pep8Args": [
Sunday, September 5, 2021
answered 1 Month ago

Within VS Code, in the bottom right of the window you will see a smiley face - to the left of that is the language the currently visible file is associated with (e.g. JavaScript). Ensure your currently opened file is a .jsx file.

Clicking this will reveal a menu at the top. Click the Configure File Association for '.jsx'..., and then choose "JavaScript React".

Saturday, September 25, 2021
David Hodgson
answered 3 Weeks ago

As others have said the warnings cannot be avoided except by suppressing them. The issue IMHO is that either you have to litter your code with annotations that apply to small scope or ignore them globally and risk errors.

IIRC there is a proposal to generate warnings where the raw types are being returned instead of at the call.

Meanwhile, I think the best approach is to use a wrapper method so that the warnings are limited to a single place, where it is safe to ignore them:

class NoWarn {
  public static Map<String, String[]> getParameterMap(ServletRequest r) 
    Map<String, String[]> result = r.getParameterMap();
    return result;

Note This answer was edited with a comment that annotations cannot be inside method bodies. That is incorrect, the above is syntactically correct. I have reverted the change.

Wednesday, October 6, 2021
answered 2 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :