Forums Register Login

Compile empty file

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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.
Why is the word "abbreviation" so long? And this ad is so short?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 930 times.
Similar Threads
Error or not Error with K&B?
Problem with LoginAction.java
protected class?
RMI error
the answer is not right?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 04:18:05.