aspose file tools*
The moose likes Beginning Java and the fly likes Debug tool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Debug tool" Watch "Debug tool" New topic
Author

Debug tool

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
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
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I am doing a Struts application in Tomcat 5.0. Which tool is for this ?

Thanks
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.)
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

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....


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Thread.dumpStack()

is what I am looking for. I appreciate all your guys responses.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Thanks, Joel. I didn't know that one. The API is just too darned big!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Debug tool