This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Difference between Compiler Error & Runtime Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Difference between Compiler Error & Runtime Exception" Watch "Difference between Compiler Error & Runtime Exception" New topic
Author

Difference between Compiler Error & Runtime Exception

Poonam Krishnam
Greenhorn

Joined: Jun 21, 2006
Posts: 1
I wanted to know the difference between Compiler Error & Runtime Exception.
Given a faulty program that how do you identify if it is a Compiler Error or a Runtime Exception ?
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Hi Poonam,

Compiler error could be a syntax error
1. Left curly braces not equal to right curly braces.
2. Semicolon missing in the end.
3. identifiers starting with digits.
4. Using wrong modifiers (top level class private) or wrong combination of modifer (abstract with static).

These are some error which compiler can catch.

In short compiler error are those which directly violate any rule of java language specification.

Whereas exception comes when something goes wrong at the time of execution of your code.
You code is fine as per JLS but may be you are doing 1/0 arithmetic operation or loading any class or file which does not exist.



Compiler can't report these errors unless and until you programme not gets executed. We call these types of errors as Exception.

"By the way its not certification question at all. Its java beginner question" and we have separate forum for that.


Naseem
[ July 13, 2006: Message edited by: Naseem Khan ]

Asking Smart Questions FAQ - How To Put Your Code In Code Tags
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
What is the difference between compile time error and run time error?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference between Compiler Error & Runtime Exception
 
Similar Threads
Exceptions
Chap 3 ,page 237 K&B SCJP5 book -Question on Wrappers from Exam Watch Section
Runtime & Compile time Error
difference between error and runtime exception
diff between checked and unchecked exceptions