Re: Basic question in eclipse....
Peter Duniho wrote:
On Mon, 07 Apr 2008 20:22:14 -0700, ankur <ankur.a.agarwal@gmail.com>
wrote:
When I do a class declaration ( without filling it) in eclipse it
creates a .class file automatically without any compilation ? How is
that possible? I mean How does that happen?
Without knowing exactly what you mean by "do a class declaration" --
that is, what steps exactly you're performing within the IDE, it's hard
to answer your question specifically.
However, I can at least share with you that Eclipse, like many modern
IDEs, includes a variety of features to speed the writing of code. This
includes automatic compilation and context-sensitive code-generation.
Auto-compile does just that...if you change the code, Eclipse
immediately recompiles the code. The code-generation stuff is less
automatic, but similarly is triggered by specific things you do while
writing your code.
In Eclipse, these features are configurable. Most people find them
helpful, but if you don't like them you can turn them off.
Specifically, Eclipse will compile your code every time you save it if you set
up the IDE or the project itself to "build automatically". If you turn that
option off, either as the default or for a particular project, the project
will only build when you select the option.
It is a best practice to to build .class files in a different directory from
that for the .java files. For applications Eclipse seems to like to put
..class files in <project>/bin/, for Web apps it likes
<project>/"Web Content"/classes/. Another popular convention is
<project>/build/ for application .class files, or whole web applications, and
<project>/dist/ for deployment files (JARs, WARs, EARs, AARs, ...). Eclipse's
choice of directory names in a project (Java Source/ vs. src/, bin/ vs.
build/, etc.) is at your command.
The "as-you-type" error checking uses an internal IDE compiler that does not
actually build the project, but checks syntax and the like right within the
editor. I don't know if Eclipse does this yet, but NetBeans uses Java's
built-in compiler libraries for this feature, which increases cohesiveness
between the IDE's syntax checks and the actual build. If Eclipse doesn't yet,
I bet it will soon. Either way, the editor compilation is separate from
build-time compilation. It is the latter that creates the .class files,
wherever you told Eclipse to put them.
--
Lew