File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to handle ExceptionInInitializerError ?
It's not a secret anymore!