This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to handle ExceptionInInitializerError ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to handle ExceptionInInitializerError ?" Watch "How to handle ExceptionInInitializerError ?" New topic

How to handle ExceptionInInitializerError ?

jami siva
Ranch Hand

Joined: Oct 16, 2009
Posts: 66

Below is my code, in this iam unable to catch ExceptionInInitializerError, iam only to catch NullPointerException Only,
Can any one make edjustments to this code to handle ExceptionInInitializerError.
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
I think you can't because ExceptionInInitializerError is a chaining exception.

maybe you can try to use
NullPointerException.getCause() to return a Throwable object and cast it to ExceptionInInitializerError

or a better approach is

jami siva
Ranch Hand

Joined: Oct 16, 2009
Posts: 66
HI Lee Kian Giap ,

I Understood this one.

Thank you very much.
I agree. Here's the link:
subject: How to handle ExceptionInInitializerError ?
It's not a secret anymore!