File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Hunting down an exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Hunting down an exception" Watch "Hunting down an exception" New topic
Author

Hunting down an exception

Andy Robinson
Greenhorn

Joined: Feb 14, 2005
Posts: 10
Hi
The lastest program I've been working on builds just fine, but outputs a nullpointer exception when run.
I've been having some difficulty tracking this null pointer down. What I'd like to konw if theres a way to run your program step by step, which would be a big help in finding it.
I'm just using the KToolbar at the moment. Would it help for me to download another development enviroment like JBuilder or something ?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I'm not familiar with KToolbar. Does it give you a stack trace when the exception is thrown? It will give you a good place to start at least.

Unfortunately, I can't offer much more advice than that as I am a relative newbie to J2ME myself.

Good luck,

Layne


Java API Documentation
The Java Tutorial
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well the stack trace should give you a clue to the exact line of code that is causing the problem.

Yes another IDE would help step through the code.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Andy Robinson
Greenhorn

Joined: Feb 14, 2005
Posts: 10
It's not giving me a stack trace, thats a big part of the problem, the exception could be anywhere
Just out of curiosity what IDE do you guys use ? How helpful are they ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Actually for J2ME I only use TextPad and compile in the Toolkit. I have used IntelliJ Idea, but I haven't tried remote debugging. Wait I take that back, for some reason I think I might have.

But in almost all cases I just read the stack trace.

Mark
Michael Yuan
author
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Try to catch the exception and use exception.printStackTrace() to print the stack trace to the console. Of course, this only works in the emulator. On the real device, your need a logging tool to log the stack trace to RMS or send it to a network server or display it on top of your app screen.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
If you run the emulator from the command-line, it should print the stack trace directly to the console, IIRC. If not, Michael's suggestion should do the trick.

Layne
Andy Robinson
Greenhorn

Joined: Feb 14, 2005
Posts: 10
Cheers everyone, the error has now been hunted down and exterminated
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hunting down an exception
 
Similar Threads
Problems with J2EE server/deploytool
CLASSPATH Environment Variable
Java-Mind-Teaser: Memory Problem with Tomcat/JSP
bit shifting
Very new to Java