• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception being thrown by JVM / Programmatically

 
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

I need some help. What is the difference between a Exception thrown by JVM and thrown Programmatically?


Regards,
A.A.Anbarasu
 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exceptions which are thrown by JVM inherits from Error class. You needn't to handle them.
 
Anbarasu Aladiyan
Ranch Hand
Posts: 182
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lukas Smith wrote:Exceptions which are thrown by JVM inherits from Error class. You needn't to handle them.



Thats ok. But how do we know an Exception is thrown by JVM?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We do not know . In some cases we can predict a little (fe. w create a huge array of objects, and we fill that array - JVM can throw an exception because of running out of memory).
If an exception of JVM is thrown - your program will crash - stop working.
How can you predict if tomorrow this time there will be raining?
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're driving somewhere, and you have bad directions, you won't get there, because the directions are faulty. That's really your fault, because you've taken directions that were faulty. That's like an Exception caused by programming. If you don't arrive where you're going because of bad directions, that's not the car's fault.

On the other hand, your car might break down, or blow up, or a tire may blow, and you can't get to where you're going. That's really an error with the car, not the directions you've been given. In the Java world, that would be like a JVM error - the JVM error just sorta blew up doing what it's supposed to do.

Both stop you from getting to where you're going, but one has more to do with the programmer(driver), while the other had more to do with the car itself (the JVM).

-Cameron McKenzie
 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Lukas Smith wrote:Exceptions which are thrown by JVM inherits from Error class. You needn't to handle them.


There are no exceptions inherited from the Error class. ALL exceptions are inherited by the Exception class; checked and unchecked
(subclasses from RuntimeException). But there is at least one Error class which are regarded as thrown by the JVM (AssertionError).

cheers
Bob
 
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
beautiful explanation by Cameron McKenzie....
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bob Wheeler wrote:

Lukas Smith wrote:Exceptions which are thrown by JVM inherits from Error class. You needn't to handle them.


There are no exceptions inherited from the Error class. ALL exceptions are inherited by the Exception class; checked and unchecked (subclasses from RuntimeException). But there is at least one Error class which are regarded as thrown by the JVM (AssertionError).


All the exceptions which are sub-classes of Error class are thrown by JVM. There are also exceptions which are sub-classes of Exception class (actually they are sub-classes of RuntimeException to be more specific) which are thrown by the JVM. All the JVM exceptions are unchecked...
 
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:All the exceptions which are sub-classes of Error class are thrown by JVM.



As per K & B book, AssertionError is thrown programmatically, not by JVM. Is that incorrect?

Ankit Garg wrote:All the JVM exceptions are unchecked...



But the reverse is not true, right? IllegalArgumentException, IllegalStateException & NumberFormatException are all unchecked exceptions, but they are thrown programmatically, not by JVM.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AssertionError is thrown progammatically and not by jvm....i think other than that all the errors are thrwn by the jvm..actually you dont have know about other errors except assertionerror
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup all the jvm exceptions(am not talking about errors here) are unchecked...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic