File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Null pointer exception on using hashtable get() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Null pointer exception on using hashtable get()" Watch "Null pointer exception on using hashtable get()" New topic
Author

Null pointer exception on using hashtable get()

Bravi kumar
Greenhorn

Joined: May 03, 2012
Posts: 3
Hi,

I am facing the null pointer exception since many days.

Could anybody please help me how to fix the above null pointer exception ?

I am copying the error trace from eclipse console window.

Caused by: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:334)
at ....tools.hmi.window.OdWinTreeChooser.setHierarchyToObject(OdWinTreeChooser.java:497)



Thanks for helping.

Regards,
Kumar.


Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2416
    
  50
Not sure why this is posted in Performance it should probably be in the beginners section. How does one get it moved?

You are probably getting an NPE because you are passing a null value to the get method. Hashtable does not allow null keys.
BTW why are you using Hashtable, most people use HashMap instead these days.
Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 186

Obviously, you have to debug and find out where exactly that get method is getting null from!


The biggest gamble will be to ask a question whose answer you know in that it will challenge your theory | www.TechAspire.blogspot.in
R. Jain
Ranch Hand

Joined: Aug 11, 2012
Posts: 375
    
    1

Hello Bravi,

You need to post some code here to get valuable input from others..
We cannot just see a random error and tell where it went wrong without even concerning about where it came from??
See PostRealCode <- click and TellTheDetails <- click
And before you post any code, see UseCodeTags <- click
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40058
    
  28
Why are you using Hashtable?

You realise Hashtable does not allow null values for keys or values, and will probably throw that Exception if you try to use pass a null parameter to any of its methods. You can verify that by reading the documentation for Hashtable and its get method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null pointer exception on using hashtable get()