Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: J2ME
Hello,
 
I got the following error message while trying to make a hangman app . Please help me out here.
 
Running in the identified_third_party security domain
java.lang.NullPointerException
	at hangman_game.hangman_game.gamevariables(+14)
	at hangman_game.hangman_game.process(+4)
	at hangman_game.hangman_game.commandAction(+12)
	at javax.microedition.lcdui.Display$DisplayAccessor.commandAction(+282)
	at javax.microedition.lcdui.Display$DisplayManagerImpl.commandAction(+10)
	at com.sun.midp.lcdui.DefaultEventHandler.commandEvent(+68)
	at com.sun.midp.lcdui.AutomatedEventHandler.commandEvent(+47)
	at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+186)
	at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)
Posted 17-Sep-11 20:13pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You get a null pointer exception when you are trying to use a variable/object when it has not been assigned/initialized.
 
From your exception the problem is in the gamevariables method, start by looking there.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Run in debug mode and place a breakpoint as it enters the gamevariables method.
Check every object has been initialised before being used.
 
If this is a regularly called method then it might be better to first run it and allow it to crash, thus letting you identify the line where it throws the exception.
 
Whatever you do, any decent Java IDE will support easy debugging tasks such as this.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Nirav Prabtani 268
1 OriginalGriff 217
2 Mika Wendelius 185
3 CPallini 170
4 _Amy 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Mika Wendelius 185
3 _Amy 170
4 CPallini 170


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 29 Sep 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100