Why am I getting Java.lang.NullPointer error?

Sometimes we have experienced with Java.lang.NullPointer error and sometimes it is so hard to predict which code producing the error. I have experienced about this error in 2007, and then I read NULL pointer exception documentation from SUN (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/NullPointerException.html) which saved my debugging time. I hope it will save yours time also.

There is only 4 reasons to get NULL POINTER EXCEPTION:

1 Calling the instance method of a null object

2 Accessing or modifying the field of a null object

3 Taking the length of null as if it were an array

4 Throwing null as if it were a Throwable value

Comments

Popular posts from this blog

There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server; ERROR

How to Convert OutputStream to InputStream

How to compile and install GraphicsMagick (GM) in Linux