Issue
I am trying to create a Java project on VS Code, and I wish to add all of the files inside the src
folder. Layout of the project:
As you can see, there are multiple subfolders inside src
, and I wish to add all of them in the java.project.sourcePaths
inside the settings.json
file so the files can run. If I leave it as "java.project.sourcePaths": ["src"],
, I got errrors which my objects created cannot be resolved to a type
.
I got this temporarily fixed by changing the direcotry into src/PA 1/
, but I do not know how to include all subfolders of src
. This means everytime I create a new subfolder, I need to come back to add it in java.project.sourcePaths
.
Is there a way to include all subfolders inside src
? I tried src/**/
but it did not work.
PS: Can any one explain why Java is not recognizing files inside the subfolder?
Solution
I don't think you need to add all the subfolders of src
to "java.project.sourcePaths"
. "java.project.sourcePaths": ["src"]
is enough.
The codes under the subfolders of src
should be structured by the package
and import
, both relative to src
.
Answered By - Steven-MSFT
Answer Checked By - Willingham (JavaFixing Volunteer)