Re: Q: Java source and directory structure - 'standard way' ?
From: Raymond DeCampo (rdecampo_at_spam-I-am-not.twcny.rr.com)
Date: 01/25/04
- Next message: Raymond DeCampo: "Re: How to specify encoding in Java?"
- Previous message: Travis Ray: "Java Newb"
- In reply to: FISH: "Q: Java source and directory structure - 'standard way' ?"
- Next in thread: FISH: "Re: Q: Java source and directory structure - 'standard way' ?"
- Reply: FISH: "Re: Q: Java source and directory structure - 'standard way' ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 03:00:38 GMT
FISH wrote:
>
> What they do is they build the package directory tree by hand, place
> their .java files into the appropriate directories, and then just
> "javac *.java" in each directory of the tree. The result is that, in
> the absense of a specified output directory, the class files end up
> right next to the source files - but this works because the source
> code directory structure has been created to mirror the package names.
>
> This isn't the first time I've seen this done - I've noted a programmer
> where I work does the same thing! And although it works, to me it is
> less than ideal. I have a hard time accepting that this is the 'standard
> way', for several reasons:
>
> 1) The compiler should be responsible for organising and creating *ALL*
> its output itself - this includes creating any directories which
> are needed for its representation of the code. The user should not
> need to work this out in advance and provide them.
>
> 2) With source and class files intermixed, packing up the source or
> creating a Jar becomes a major headache. Surely the output direct
> -ories should remain _pure_, containing only those files which form
> the package?
>
> 3) This scheme pre-supposes that Java compilers will always use direct-
> ories to model their package hierarchy - which might not always be
> the case.
>
> I can think of a handful of other reasons why I think this scheme is
> inferior, but I think I've already made my point...! :-) So, the
> question is... Is this *really* the 'standard way' (or conventional
> way) of holding Java source - or are all these coders just ignorant
> of the -d switch ???
>
Fish,
I think to say that organizing the source code in this manner is
standard. Many Java IDEs expect the code to be this way and some
compilers will even emit warnings or errors if it is not.
However, it is not as bad as it seems. You can still use the -d option
even when the source code is arranged this way. So you can still
separate the source code and the class files easily.
Let me address your concerns:
1) The compiler does create the output; the source code and the
directories it is contained in are input.
2) One can still use the -d flag to separate source and class files.
3) I was going to dismiss this concern as silly, but the JLS does
explicitly mention using a database to store classes, so that would have
been wrong of me. However, I doubt this is a serious concern for the
near future.
Finally, let me suggest that you try out ANT. ANT provides a way of
easily specifying how to build your code. It can run the compiler and
jar the files. As an added bonus you can distribute the build script
and everyone working on the code will be able to build it in the same way.
Good luck with your future endeavors,
Ray
- Next message: Raymond DeCampo: "Re: How to specify encoding in Java?"
- Previous message: Travis Ray: "Java Newb"
- In reply to: FISH: "Q: Java source and directory structure - 'standard way' ?"
- Next in thread: FISH: "Re: Q: Java source and directory structure - 'standard way' ?"
- Reply: FISH: "Re: Q: Java source and directory structure - 'standard way' ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|