Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stack trace

 
duhit Choudhary
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
Can anybody tell me how to get stack track of the java program in order to get the program flow?
Thanks in Advance.
 
ganapathi sundaram
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you can use printStackTrace() of the method from the exception object.

try{
}catch(Exception e){
e.printStackTrace();
}

As well, if you want to read entire stack trace to store it in another variable , you can try below

public java.lang.StackTraceElement[] getStackTrace();

StackTraceElement[] traces = null;
try{
}catch(Exception e){
traces = e.getStackTrace();
}

All the best..!
 
Jan Hoppmann
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The current thread has a getStackTrace()-method as well.
 
Ivan Jozsef Balazs
Rancher
Posts: 981
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not even necessary to catch an exception in order to access the stack trace.

 
duhit Choudhary
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks to all of you.. i'll try to do all of your methods and will see which one is working for me !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic