Java Reference
In-Depth Information
try {
// Get a Reader for the script file
Reader scriptReader = Files.
newBufferedReader(scriptPath);
// Execute the script in the file
engine.eval(scriptReader); // First time, add a
// breakpoint here
}
catch (IOException | ScriptException e) {
e.printStackTrace();
}
}
}
As the first step in debugging the script, you need to set a breakpoint at the line of
code that calls the
eval()
method of the script engine. Without performing this step, you
will not be able to step into the script from the debugger. Figure
13-5
shows the code of
the
PrimeTest
class with a breakpoint at line 35.
Figure 13-5.
The code of the PrimeTest class with a breakpint at line 35 in the
NetBeans IDE
The next step is to start the debugger. You can use
Ctrl + Shift + F5
when the
editor pane containing the
PrimeTest
class is active. The debugger will stop at the
breakpoint at line 35. You need to step into the
eval()
method call by pressing
F7
; this
will take you to the
AbstractScriptEngine.java
file, as shown in Figure
13-6
.
Search WWH ::
Custom Search