Is there a way to print a stack trace on the screen in Java ME?

I have code that looks like this, which is great for displaying a message, but cannot determine how to capture the stack trace.

try { throw new RuntimeException("This is bad stuff!"); } catch (Exception e ) { mainForm.append("Exception: " + e.getMessage()); } 

Calling e.printStackTrace () sends it somewhere that I cannot find.

+4
source share
4 answers

see this article: http://lwuit.blogspot.com/2008/12/redirecting-output-on-s60-devices.html

too bad, no System.setErr (PrintWriter) or Thread.getStackTrace ()

I do not think there is a (general) solution for this problem

+4
source

No, you can’t. The stack trace is always printed to System.err, and there is no way in CLDC to redirect System.err to another location.

+1
source

Even in CLDC 1.1 this does not exist. Sun's hope includes redirecting errors and exiting the stream in future versions. This is very important for logging / debugging.

+1
source

I created a tool that can be used to register the correct stack traces also in the CLDC. Check it out at http://jarrut.sourceforge.net . It is still very new, and it may have rough edges, but it works for me, and I could no longer imagine the development of MIDlet. The best way to use it is to combine it with a microlon.

0
source

All Articles