X

Geertjan's Blog

  • March 31, 2015

YouTube: Debugger for JDK8’s Nashorn JavaScript in NetBeans IDE

Geertjan Wielenga
Product Manager
Since the release of JDK 8 and NetBeans IDE 8, NetBeans has provided a built-in debugger for JDK8's Nashorn, the new lightweight high-performance JavaScript runtime built on top of the JVM.

With NetBeans IDE, you can add breakpoints to your Nashorn scripts and go through them when debugging your Java application. When you're debugging, you can step where no developer has stepped before: from your Java code into your JavaScript code.

To see this in action, watch this quick 5 minute screencast. Together with seeing Java and Nashorn being debugged together seamlessly, you'll see that Nashorn can also be integrated into a NetBeans module, i.e., you're able to extend NetBeans IDE via JavaScript!

Join the discussion

Comments ( 2 )
  • Deven Phillips Friday, May 1, 2015

    I am trying to debug a JavaScript file which is run inside of Nashorn, but when I set a breakpoint inside of a JavaScript closure the thread is never paused. IS setting breakpoints inside of closures not supported?

    Example:

    // Receive message from the browser and then broadcast those message back out to all connected clients.

    eb.consumer("client.to.server").handler(function(message) {

    console.log("Message from client: "+message.body().content);

    var reply = message.body();

    var msgTime = new Date();

    reply["timestamp"] = msgTime.toLocaleDateString()+' '+msgTime.toLocaleTimeString();

    eb.publish("server.to.client", reply);

    // eb.send("store.message", [reply.user, msgTime.toISOString(), reply.content]);

    });

    I've been setting a breakpoint on the console.log() line and the debugger never catches that breakpoint. Any suggestions?


  • yikes aroni Wednesday, May 13, 2015

    You pass a string of code in to engine.eval(..). When I do that, it breaks the association between the file (in which i place the breakpoint) and the code (i.e., the string of code i passed into eval()). Is there some magic that makes this work for you?

    Also, since my code is not Netbeans specific (it will run outside of the IDE) and thus i can't use FileObject. Is there some specific aspects of the string returned by asText() that makes this work?


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services