aspose file tools*
The moose likes Java Micro Edition and the fly likes NullPointerException in a problematic point of code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "NullPointerException in a problematic point of code" Watch "NullPointerException in a problematic point of code" New topic
Author

NullPointerException in a problematic point of code

Lauri Juhani Martikainen
Greenhorn

Joined: Sep 03, 2009
Posts: 3
In one of my NetBeans 6.5.1 projects
there is an ordinary MIDlet
which should be able to change the Canvas used by the MIDlet
in method startApp.
The MIDlet class is as follows:

public class OSMIDlet extends MIDlet implements CommandListener
{
...

/**
* Called when MIDlet is started.
* Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
*/
public void startApp() {
if (midletPaused) {
resumeMIDlet ();
} else {
initialize ();
startMIDlet ();
}

WelcomeJK pictureSequence = new WelcomeJK (this);

Display.getDisplay (this).setCurrent (pictureSequence);



midletPaused = false;
}

...

} /* end class 'OSMIDlet' */


Now when using the debugger of NetBeans 6.5.1 IDE
it turns out that the line

Display.getDisplay (this).setCurrent (pictureSequence);

causes a NullPointerException to be thrown.
It seems that trying to catch that exception does not help
in finding out where the problem is since
it really seems that the Display object
given by Display.getDisplay (this) is null
while there should be existing a reference to a valid object.
Method Display.setCurrent (Displayable?) should not
throw a NullPointerException if variable pictureSequence is null.

Could you please help me to resolve this problem? Thank you.

Kind regards,

Lauri J. Martikainen
 
wood burning stoves
 
subject: NullPointerException in a problematic point of code
 
Similar Threads
null pointer exception
difficulty exiting a MIDlet on the WTK20 simulator
Getting Battery Level
[N95/S60] Unhandled Exception when using try/catch block
client connecting to server on cell phone app