How do I debug a JavaScript program using Nashorn?
I need to be able to debug JS code executed by Nashorn ie:
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 programmatically jump through the lines (implement a debugger).
I know intelliJ and NetBeans have implemented this, so it should be possible, but I can't find any API in Nashorn that allows stepping and / or displaying strings or variables.
Any advice / links would be most welcome. Thanks in advance.
+3
source to share
1 answer
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/
Alternatively, you can try using askari. This is the prototype that allows you to execute JavaScript code
https://github.com/wickund/nashornexamples/tree/master/askari
Cheers, Vik
+4
source to share