| Author |
Compile empty file
|
Gaurav Pavan Kumar Jain
Ranch Hand
Joined: Mar 19, 2007
Posts: 168
|
|
Hi all I created a blank file and save it as First.java When I compile it it compile successfully no error occur. I write nothing In that fie. Please let me know how compiler treat such files.
|
 |
sadasiva kumar
Ranch Hand
Joined: Oct 30, 2003
Posts: 84
|
|
First.java compiles without any errors.But when we run First.java application ,it ll not execute.You ll get Runtime error. Exception in thread "main" java.lang.NoClassDefFoundError:First regards SADASIVAKUMAR UTTI SCJP1.4
|
SADASIVAKUMAR UTTI, SCJP1.4
A bend in the road is not the end of the road ... unless you fail to make the turn.
|
 |
JB Ramesh
Greenhorn
Joined: Jan 09, 2007
Posts: 20
|
|
I also want to know why empty file is allowed by compiler. Anyway while runnning it will give runtime error. And that file can not be referred as an object also. Then why java creaters allow the empty file ? The compiler can ignore it right ? Is there any technical funda behind this ??  [ March 20, 2007: Message edited by: JB Ramesh ]
|
 |
Andy Morris
Ranch Hand
Joined: May 30, 2004
Posts: 78
|
|
So when you say it compiles successfully you're saying it produces a .class file? I'd be very suprised if it did. The runtime exception you're getting isn't because it's running an 'empty' class file, it's because the class file doesn't exist. I doubt anyone here can tell you why the designers of Java decided not to warn you (or abort compilation) if it finds an empty .java file. My only thoughts are that an empty java file has no negative impact, so why bother failing compilation over it? I'd have thought a compiler warning would be useful though.
|
 |
 |
|
|
subject: Compile empty file
|
|
|