Skip to main content
gamedev.net
🔒 Locked

[java] Java print out null

Started by dande Jun 1, 2006 at 4:29 PM 4 replies 1.8k views
Original Post
dande
dande
Hello! I am experiencing a little problem. I am currently finishing my game, and I am experiencing an error infrequently. I can run the game correctly many times, but sometimes Java prints out a null to the text output and the game will run further but the screen is not updating, and I can't really do anything. I just can't find out what this 'error' means. Any ideas?
Dan FeketeThe Shadowhand Co.If everybody has it's own matrix, then mine is an identity
philcuk
philcuk
It sounds like something is throwing a NullPointerException, which you have in a try/catch blocks, although the catch block is probably empty or not doing what it's meant to do so when the Exception is thrown your game just stops.

Try putting System.out.println(ex); in all your catch blocks and see if it prints out an exception when it also prints out "null."

I guess you are calling System.out.println(someobject); and where it would normally print out someobject.toString() the object is invalid so it's just printing "null." Look around for cases where you might have done that, it might give you an idea as to what is causing the problem.

Good luck!
dande
dande
Hi, thank your the fast reply, I've tried what you've said, it is between a try-catch block, and I've taken out all System.out.println -s from my project. Still happens rarely, and that's what is strange to me, how come this error only happens infrequently? Actually, I forgot to mention, that it happens when I start the program, no difference between two "startups". Sometimes happen, sometimes not. :s
Dan FeketeThe Shadowhand Co.If everybody has it's own matrix, then mine is an identity
RinusMaximus
RinusMaximus
Which IDE are you using? If you use Eclipse you could make an Exception Breakpoint. Try Debugging your game and add an Exception Breakbpoint for NullPointerException. That might help you catch the cause of the exception.

BTW, what do you mean with text output? Is that your console e.g. the place where tour System.out's print to? If it is still printing null there are probably still System.out's hanging around. Maybe in any third party libraries you're using?

capn_midnight
capn_midnight
This is probably a null reference somewhere in your code. You may not have initiallized something. NullReferenceException extends RuntimeException, which is the only type of exception that is not checked at runtime. An unhandled NullReferenceException will unroll up and out of the thread in which it occurs, and then be printed to System.err (and now System.out). It must be in your render loop somewhere, so it is killing your rendering thread but not killing the Swing (or AWT) worker process.

Topic Locked

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

Sign in to reply to this topic.