aspose file tools*
The moose likes Beginning Java and the fly likes NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException" Watch "NullPointerException" New topic
Author

NullPointerException

Phillipe Rodrigues
Ranch Hand

Joined: Oct 30, 2007
Posts: 165
What can be the exact cause of this below err?

java.lang.NullPointerException
at MVC.Example1.doGet(Example1.java:30)
at MVC.Example1.doPost(Example1.java:56)


Thanks,
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
What can be the exact cause of this below err?

java.lang.NullPointerException
at MVC.Example1.doGet(Example1.java:30)
at MVC.Example1.doPost(Example1.java:56)
--------------------

Thanks,



It would be difficult to answer your question without seeing your code. It seems that the reference variable is not initialized properly, but you have tried to access the methods associated with the reference. For example,


the above code snippet will throw NPE since str is not initialized.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

Something in line 30 of Example1.java is null when it isn't supposed to be.

NullPointerExceptions are usually easy to solve - just look carefully at the line where the error occurs to see what could be null there.

Since you didn't post the source code, we can't tell you exactly what's wrong. So if you don't see it yourself, show us the code.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException