• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

lerning debug

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI
im developing a web based program without the need of debuging(debug.exe). i use IDE to develop my program and i saw the tearms "breakpoint" ,"trace in" and im not sure that they like me , can you give me a good start place to learn the debug tool??
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each IDE's debug tools are a bit different, and usually there is a built-in tutorial under the Help menu.

But as a generic help:
Breakpoint is a point in your code that you want your program to run up to.. and then pause the execution. You would normally do this if you know a very large section of your code works, and you want it to run normally until you get to the certain section of code that doesn't work quite right. At this point it enters the 'debugging mode' and you can 'step' through the program one line at a time. You would do this to examine what happens at each step in your code, and to see what variables contain what values.

Tracing usually involves some sort of diagnostic output, like a logging file. I've never used this kind of feature though, i usually go for simple System.out.println's
 
Shay Gaghe
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Curwen:
Each IDE's debug tools are a bit different, and usually there is a built-in tutorial under the Help menu.

But as a generic help:
Breakpoint is a point in your code that you want your program to run up to.. and then pause the execution. You would normally do this if you know a very large section of your code works, and you want it to run normally until you get to the certain section of code that doesn't work quite right. At this point it enters the 'debugging mode' and you can 'step' through the program one line at a time. You would do this to examine what happens at each step in your code, and to see what variables contain what values.

Tracing usually involves some sort of diagnostic output, like a logging file. I've never used this kind of feature though, i usually go for simple System.out.println's


thanks for he reply Mike
why do you prefer to use System.out.println instead of debug and what's the benfits to use each of them?
thanks
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are many times where I won't necessarily start up the IDE to make a simple little change.

I'll just open the java source file, make my small change, recompile from the command line, and run my program again.

In this case I'm not inside the IDE, so using the debugging facilities is not available to me.

Now that is by choice.. there are other times when IDE debugging is not available without (it seems) major pains. For example, if you develop servlets or EJB's, you need to package and deploy these classes... and unless you know how to make your IDE do remote and distributed debugging, System.out.println seems much simpler.

So having a diagnostic System.out.println("the new value is: " + variable) or System.out.println(" ** inside servlet init: about to initialize db connection") is pretty handy. For a trick on how to efficiently do this sort of thing, see: http://www.javaranch.com/ubb/Forum33/HTML/003433.html

But for other cases, I really do like the debug facility, being able to hover my cursor over a variable and peek inside it, being able to step through a program, line by line until it breaks. These are advantages too.

But my main reason for IDE's these days is CLASSPATH management and the popup help (type a dot and be presented with a list of what you could type next - saves typing)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic