James Raitsev
James Raitsev

Reputation: 96491

Java Project vs Maven Project (Eclipse), dir structure clarification needed

When i create a new Maven project in Eclipse, directory structure contains both src/main/java and src/main (down below)

Question: I understand my code should fall under src/main/java, what is the purpose of the src/main? Why does Eclipse create it?

enter image description here

Upvotes: 9

Views: 13065

Answers (3)

JustinKSU
JustinKSU

Reputation: 4999

You can have other sub-directories under src/main that are not source files. If you see Maven documentation you need to have resource files under src/main/resources. Obviously the parent directory src/main needs to be created to create child directories.

Upvotes: 3

Paul Whelan
Paul Whelan

Reputation: 16799

For src/main/java to exist src/main/ must first exist so eclipse just shows you all the folders in your project including src/main/

If you want to remove them from your view in package explorer, you can create a filter for the package explorer view and exclude Non-Java elements.

Look for the down arrow in the top right of the package explorer view for the filters option.

Upvotes: 7

HJW
HJW

Reputation: 23443

src/main/java is Maven's standard layout for placement of your Java source codes.

Check http://java.sg/maven-standard-directory-layout/ for a list of standard Maven directories.

src/main/java       Application/Library sources
src/main/resources  Application/Library resources
src/main/filters    Resource filter files
src/main/assembly   Assembly descriptors
src/main/config     Configuration files
src/main/webapp     Web application sources
src/test/java       Test sources
src/test/resources  Test resources
src/test/filters    Test resource filter files
src/site        Site
LICENSE.txt     Project's license
NOTICE.txt      Notices and attributions required by libraries that the project depends on
README.txt      Project's readme

Upvotes: 10

Related Questions