5

I need to be able to Debug JS code run by Nashorn i.e:

ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine engine = sem.getEngineByName("nashorn");
engine.eval("load (\"src/com/sap/rdl/runjs/file.js\");");

Now I need to add a breakpoint in the JS file and be able to step through the lines programmatically (implement a debugger).

I know intelliJ and NetBeans implemented this so it should be possible, yet I cannot find any API in Nashorn that allows stepping and/or mapping of lines or variables.

Any advice/links would be most welcome. Thanks in advance.

3

1 Answer 1

5

You can debug your code in Intellij IDEA.

http://blog.jetbrains.com/idea/2014/03/debugger-for-jdk8s-nashorn-javascript-in-intellij-idea-13-1/

Also, you can try to use askari. It's a prototype that allow you to step through JavaScript code

https://github.com/wickund/nashornexamples/tree/master/askari

Cheers, Vik

Sign up to request clarification or add additional context in comments.

2 Comments

I need to do it programmatically - meaning i need to write code that does it not use some IDE to do it. We are implementing a debugger so i do need to reinvent the weel here :) any articles/ relevant people contacts would be most welcome
Nashorn uses the jvmdi API for debugging with additional support provided in Nashorn's Debugger support class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.