Why do Java source files go into a directory structure?
Posted
by bdhar
on Stack Overflow
See other posts from Stack Overflow
or by bdhar
Published on 2010-06-09T10:09:47Z
Indexed on
2010/06/09
10:12 UTC
Read the original article
Hit count: 236
Suppose that I am creating a Java project with the following classes
com.bharani.ClassOne
com.bharani.ClassTwo
com.bharani.helper.HelperOne
com.bharani.helper.support.HelperTwo
with files put immediately under the folder 'src'
- src/ClassOne.java
- src/ClassTwo.java
- src/HelperOne.java
- src/HelperTwo.java
and compile them using the command
$ javac src/*.java -d classes (assuming that classes directory exists)
The compiler compiles these files and put the class files in appropriate sub-directories inside the 'classes' directory like this
- classes/com/bharani/ClassOne.class
- classes/com/bharani/ClassTwo.class
- classes/com/bharani/helper/HelperOne.class
- classes/com/bharani/helper/support/HelperTwo.class
Because the spec mandates that the classes should go inside appropriate directory structure. Fine.
My question is this: When I use an IDE such as Eclipse or NetBeans, they create the directory structure for the source code directory ('src' directory here) also. Why is that? Is it mandatory? Or, is it just a convention?
Thanks.
© Stack Overflow or respective owner