9
votes

Is there any standard directory layouts for Java projects? What layout do you prefer most?

I'm asking about more complex layout than just 'src' and 'bin' in project's directory (i.e. where do you put your test classes, build configurations, etc.?).

Thanks in advance.

5

5 Answers

6
votes

I usually use /src for source code, /test or /tst for test code, /build for class files, /lib or /libs for dependencies, /dist for my JAR and libraries (so I can just compress the directory and distribute it without thinking), and /docs for documentation (including JavaDoc). My Ant build script goes in the directory that the ones I named are subdirectories of.

When I build, I create the JAR from /build and copy /lib and maybe /docs into /dist.

4
votes

Are you using any build tools? Like Maven for example? If not, you probably should - and in that case your directory layout would be predefined for you.

2
votes
0
votes

I use:

programming
  - distro
  - java
      - lib
      - src
          - com...
          - net...
          - org...
      - tools

And I compile classes side-by-side with the sources, and package from there to a subdirectory of distro.

0
votes

For web projects I usually use:

<project name>
  dev
    src
    lib
    www
    build.xml
  build
    www
    bin
  www

The www folder in src is the original. The www folder in build is where that gets combined with the contents of similar folders to produce what needs to be uploaded. The www folder outside is where I run a local copy, complete with temporary files and other such garbage. I have an ant script in build.xml to copy things around.

I'd like to know if there is any sort of standard.