• Share this article:

Debug JavaScript? Using Eclipse?

Friday, March 2, 2007 - 02:00 by Wayne Beaton

I mentioned earlier that I have been working with the Eclipse Ajax Toolkit Framework (ATF). Before today, my experience with JavaScript has been limited, and generally involved a lot of screaming in frustration. This afternoon, I spent some time with the ATF JavaScript debugger.

The best part is that the JavaScript debugger looks a heck of a lot like the Java debugger. There’s a good reason for this, as the same debugging infrastructure is leveraged by both. If you’re familiar with Java debugging in Eclipse, JavaScript debugging is a breeze. It starts by right-clicking on your file and selecting “Debug As > Debug in Mozilla” from the pop-up menu.

In the diagram, you see the standard “Debug” and “Variables” views while debugging my lame Fibonacci number calculation example. At this point, we’re a few levels into the recursion as evidenced by the depth of the stack in the “Debug” view. Variable values for the highlighted frame are displayed (as expected) in the “Variables” view. The “Step Into”, “Step Over”, “Step Return”, “Resume”, and “Terminate” buttons all work as expected.

Now that I have a JavaScript debugger, it’s time for me to start doing some actual Ajax stuff…