"Simple" J2SE projects
As cletus explained, the structure of the source directory is directly equivalent to the structure of the package and, in fact, is built into Java. Everything else is a little less clear.
Many simple projects are organized manually, so people can choose a structure in which they feel good. What is often done (and this is also reflected in the project structure in Eclipse, the very dominant Java tool) is to have the source tree begin in a directory called src . Your source files without packages will be located directly in src, and your package hierarchy, usually starting with the com directory, will also be contained in src . If you CD into the src directory before running the javac compiler, your compiled .class files will fall into the same directory structure, with each .class file located in the same directory and next to its .java .
If you have a lot of source and cool files, you want to separate them from each other to reduce clutter. The management and organization of Eclipse often places the bin or classes directory parallel to src , so .class files fall into a hierarchy that reflects the src structure.
If your project has a set of .jar files for delivering capabilities from third-party libraries, then the third directory, usually lib , is placed in parallel with src and bin . Everything in lib must be placed in the classpath for compilation and execution.
Finally, there is a bunch of this and what is more or less optional:
- docs to
doc - resources in
resources - data in
data configuration - in
conf ...
You get the idea. The compiler does not care about these directories, these are just ways to organize (or confuse) yourself.
J2EE Projects
J2EE is roughly equivalent to ASP.NET, it is a massive (standard) structure for organizing web applications. Although you can design your code for J2EE projects as you wish, there is a standard standard for the structure that the web container expects from your application. And this structure, as a rule, is also slightly reflected in the original layout. Here is a page that details project structures for Java projects (they don’t really agree with what I wrote above) and for J2EE projects in particular:
http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
Maven Projects
Maven is a very versatile project building tool. Personally, my building needs are perfectly met by ant , which roughly compares to nmake . Maven, on the other hand, is a full-lifecyle of construction management with addiction management bolts. Libs and the source for most of the code in the Java world are freely available on the web, and maven, if asked beautifully, will scan it for you and bring home everything you need without even having to talk about it. He also manages a small repository.
The disadvantage of this extremely hardworking seeker is the fact that he is very fascist regarding the structure of the project. You do it in a Maven way or not at all. By making his standard go down, Maven manages to make projects around the world more similar in structure, easier to manage, and easier to create automatically with minimal input.
If you ever choose Maven, you can stop worrying about the structure of the project, because there can only be one. This is it: http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html