Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

Basic question in eclipse....

Thread view: 
ankur - 08 Apr 2008 04:22 GMT
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? BTW I feel eclipse
compiles the code by itself...is that correct ? The eclipse IDE throws
compilation errors as the code is typed.

If I use command line option using javac then class file is not
generated if the code as syntax error whereas in eclipse .class file
is generated as soon as the class is declared and even though later on
as the class is filled the code might have syntax error!

Thanks,
Ankur
Peter Duniho - 08 Apr 2008 04:30 GMT
> 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.

Pete
Lew - 08 Apr 2008 05:40 GMT
>> When I do a class declaration ( without filling it) in eclipse it
>> creates a .class file automatically without any compilation ? How is
[quoted text clipped - 14 lines]
> 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.

Signature

Lew

Arne Vajhøj - 09 Apr 2008 00:50 GMT
> 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? BTW I feel eclipse
> compiles the code by itself...is that correct ?

Eclipse builds every time you save.

>                                          The eclipse IDE throws
> compilation errors as the code is typed.

And it also parse what you type.

> If I use command line option using javac then class file is not
> generated if the code as syntax error whereas in eclipse .class file
> is generated as soon as the class is declared and even though later on
> as the class is filled the code might have syntax error!

As soon the class is created it is a valid Java source. That valid
Java source is compiled to a class file.

If you then type something syntactically wrong, then it does not
compile anymore, but then the existing class file are just not
overwritten and are still there.

Arne
Lew - 09 Apr 2008 01:24 GMT
> Eclipse builds every time you save.

Unless, as I do, you turn that option off and build only when you select the
menu item do so.

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.