While creating one folder in src directory in one project in eclipse, it makes that folder a package. Is there any way to avoid this folder from automatically being a package? e.g., I add main folder in src directory. I don't want it to become a package. How can I do this?
Suppose I add folders in this manner: src/main/org/apache. I don't want main.org.apache to be a package, instead, I want the packaging to start from org. (i.e., org.apache).
The Folder Wizard (File → New → Folder) can be used to create a new folder.
I would suggest to add a resources folder at the top of your app tree so that your data and your classes are separated. But if you want to just add subpackage, do not create a new folder, just create a new package such as app. models. Folder1.
Right-click the folder, choose Build Path, then Use as Source Folder.
Manually create src/main/resources path If the resources folder already isn't present in your maven project , you can just create the “resources” folder manually under src/main folder. Once the src/main/resources folder is created, we can add the resources in this path.
Eclipse forces you distinguish between source directories and ordinary folders. Any subdirectories in a source folder will be considered a package.
In your case, you can create an ordinary folder outside of src/
to prevent the subdirectories from being interpreted as packages.
Alternatively, you can modify the project properties to have src/
be considered an ordinary directory, and put a source directory within it.
You can manage which directories in a project are considered source directories by:
Properties
.Java Build Path
. In the right pane, select the Source tab
.You need to go to Project -> Properties -> Java Build Path -> Source (tab).
Remove src
from "Source Folders on Build Path"
Then add src/main
as a source folder. If you already have org
under main, then your packages should start with org
as desired.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With