Skip to main content
gamedev.net
🔒 Locked

[java] Why do I get this Java console error message...

Started by nowan Oct 8, 2001 at 8:53 AM 8 replies 500+ views
Original Post
nowan
nowan
I sometimes get this error message when running my applet: java.lang.NullPointerException at CityBoy.update at com/ms/awt/WComponentPeer.doUpdate at com/ms/awt/WComponentPeer.doUpdate at com/ms/awt/WUpdate.run at com/ms/ui/windowmanager/RunnableMessage.run at com/ms/awt/WSystemQueue.getMessage at com/ms/awt/WEventQueue.getNextEvent at java/awt/EventDispatchThread.run I don''t get it every time but quite often. Thanks for any help. nowan
rapso
rapso
somewhere you''re using a NULL pointer.. debug it and catch the exception
bslayerw
bslayerw
Start by looking in your CityBoy.update method. That''s where the NullPointer exception is coming from.

-Byron
nowan
nowan
Thanks for your replies. What exactly is a NullPointer exception
and what needs to be done to it?
DDnewbie
DDnewbie
It will emerge when using a pointer to null, duhh
something like this:
    Weapon ref = new Weapon();
Weapon ref2 = ref;
yadda,yadda...
ref = null;
ref2.use(); // EXCEPTION!! ref2 points at null/nothing



It doesn't mean that it HAVE to like that, it's one possible error.
Anyway, the thing is that you are using a ptr that you thought pointed to an object, but somehow the object doesn't exist, it has been discarded.

PS. why is it called pointer!?? shouldn't it be called NullReferenceException? Hmmm, don't know.

regards

/Mankind gave birth to God.

Edited by - silvren on October 9, 2001 5:13:55 AM
/Mankind gave birth to God.
nowan
nowan
the error message points to this line specifically:

cjv.draw(offGrfx);

but doesn''t seem to affect the running of the applet.
rapso
rapso
maybe

cjv
or
offGrfx
is a NULL-pointer
DDnewbie
DDnewbie
I would bet that rapso is right.


/Mankind gave birth to God.
/Mankind gave birth to God.
bslayerw
bslayerw
NullPointer exception means that your "reference" is pointing to absolutely nothing. You might not have initialized the reference. For Example:
//a valid reference that will throw a NullPointerException:
Object myRef;
myRef.toString();//this line will throw a NullPointerException

//a valid reference that will not throw a NullPointerException:
Object myRef;
myRef = new Object();//it is now pointing to an object in memory
myRef.toString();//this line will NOT throw a NullPointerException

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.