Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

maven

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

like image 683
James Raitsev Avatar asked May 23 '11 15:05

James Raitsev


People also ask

What is the difference between project and Java project in Eclipse?

Simple: Project is for more about embedded prgramming and java-project is for only with java-classes in package, you can place modules in source-folders but that's dirty work.

Is a Maven project comes with a specific folder structure?

Maven project structure defines a folder in order to store all resources and files needed by a web application. Inside this folder you can put all the required files for a web application like jsp files, js files, html files, css files, template files, reports files, WEB-INF files (like web. xml), META-INF files, etc…

How is Maven project different from Java project?

Many may give just a normal answer like “Maven has the ability to download dependencies automatically based on the dependencies block you put in respective maven project's pom. xml file”. Yes, that's true and its one of the major bonus point of maven based java project.


2 Answers

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
like image 88
Oh Chin Boon Avatar answered Oct 10 '22 15:10

Oh Chin Boon


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.

like image 33
Paul Whelan Avatar answered Oct 10 '22 16:10

Paul Whelan