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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException in a problematic point of code