• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Debug tool

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Debug tool

When java has some error, we could use "e.printstack()" to see the error message, and we could how the application goes step by step , one class by class, function by function. That is very helpful.

But the problem, these info will be there just when java has error exception. My question, when we run a non-exception application, how could I see those message, step by step , one class by class, function by function ?

Any suggestion ?

Thanks
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's called a "debugger", and Integrated Development Environments (IDEs) like Eclipse (www.eclipse.org), NetBeans (java.sun.com), IntelliJ IDEA (www.jetbrains.com) and JBuilder have nice graphical ones. There's even a simple command-line debugger, "jdb", that comes with the JDK.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am doing a Struts application in Tomcat 5.0. Which tool is for this ?

Thanks
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learning your debugger is a good thing, but ...

You're probably accustomed to seeing stack traces only when you catch an exception. But you can create an exception and print the trace (without throwing or catching it) any time:

new Exception("debugging only").printStackTrace();

This is absolutely not something you'd want to leave in production code because creating the exception is rather expensive and printing messes up your log. I did this once when we had no idea how a particular cache was getting cleared at very infrequent intervals but took it out as soon as the mystery was solved.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Edward Chen:
I am doing a Struts application in Tomcat 5.0. Which tool is for this ?

Thanks



I think most of these can actually debug code running in Tomcat. Certainly IDEA and Eclipse can (with the proper plug-ins.)
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stan James:

new Exception("debugging only").printStackTrace();



Why not simply Thread.dumpStack()? Not that I think Thread.dumpStack() is any more efficient; it does the same thing, methinks....
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thread.dumpStack()

is what I am looking for. I appreciate all your guys responses.
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Joel. I didn't know that one. The API is just too darned big!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic