views:

5202

answers:

4

How can I debug javascript in eclispe. I am using eclipse 3.2.1. Everytime I click on the side it gives option for adding bookmark but no break point. Could youone assist me on this.

+3  A: 

I don't believe Eclipse has a JavaScript debugger - those breakpoints are for Java code (I'm guessing you are editing a JSP file?)

Use Firebug to debug Javascript code, it's an excellent add-on that all web developers should have in their toolbox.

matt b
+2  A: 

JavaScript is executed in the browser, which is pretty far removed from Eclipse. Eclipse would have to somehow hook into the browser's JavaScript engine to debug it. Therefore there's no built-in debugging of JavaScript via Eclipse, since JS isn't really its main focus anyways.

However, there are plug-ins which you can install to do JavaScript debugging. I believe the main one is the AJAX Toolkit Framework (ATF). It embeds a Mozilla browser in Eclipse in order to do its debugging, so it won't be able to handle cross-browser complications that typically arise when writing JavaScript, but it will certainly help.

Daniel Lew
+2  A: 

I'm not a 100% sure but I think Aptana let's you do that.

Luke
I'll have to try Aptana sometime, I keep hearing good things about it, and this just adds to the list.
Daniel Lew
+1. Aptana will let you debug javascript in both firefox and (if you pay for the pro version) IE.
Gabe Moothart
A: 

I tried to get aptana running on my ubuntu 10.4. Unfortunately I didn't succeed. Chrome on the other hand, has an eclipse plugin that lets you debug javascript that's running in a chrome instance. Works very well. YOu'll have to install the eclipse plugin you'll find here:

http://code.google.com/p/chromedevtools/

Set Breakpoints in the javascript sources you edit in eclipse and browser your page in chrome. As soon as a javascript breakpoint is hit, the eclipse debugger halts and lets you step into, step over, browse the variables etc. Very nice!