Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug JavaScript in Eclipse

People also ask

Can we debug JS code in Eclipse?

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.

How do I run a debug script in Eclipse?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.


In 2015, there are at least six choices for JavaScript debugging in Eclipse:

  • New since Eclipse 3.7: JavaScript Development Tools debugging support. The incubation part lists CrossFire support. That means, one can use Firefox + Firebug as page viewer without any Java code changes.
  • New since October 2012: VJET JavaScript IDE
  • Ajax Tools Framework
  • Aptana provides JavaScript debugging capabilities.
  • The commercial MyEclipse IDE also has JavaScript debugging support
  • From the same stable as MyEclipse, the Webclipse plug-in has the same JavaScript debugging technology.

Adding to the above, here are a couple of videos which focus on "debugging JavaScript using eclipse"

  • Debugging JavaScript using Eclipse and Chrome Tools
  • Debugging JavaScript using Eclipse and CrossFire (with FB)

Outdated

  • The Google Chrome Developer Tools for Java allow debugging using Chrome.

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.


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


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!


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.