Open nicolalandro opened 2 years ago
Having the same issue, were you able to find a solution?
@santiagobasulto : iJava kernel is using jdk.jshell.JShell
, but all the commands like /list
are defined downstream from that inside jdk.internal.jshell.tool.JShellTool
, and hence are not known in the Jupyter environment, and you have to use JShell API directly to achieve a similar effect.
On top of that, you can't directly access JShell in IJava. I just opened a task in JJava (a supported descendant of IJava) to expose JShell, so hopefully we'll have it soon - https://github.com/dflib/jjava/issues/27
In the meantime, you can use reflection. Here is an example from JJava that can be easily converted to IJava:
import org.dflib.jjava.*;
import org.dflib.jjava.execution.*;
import jdk.jshell.*;
// access JShell via reflection
var kernel = JJava.getKernelInstance();
var f = kernel.getClass().getDeclaredField("evaluator");
f.setAccessible(true);
JShell sh = ((CodeEvaluator) f.get(kernel)).getShell();
// use JShell API to emulate JShell commands
sh.snippets().forEach(s -> System.out.println(s))
I try to do this instructions:
But the result is:
How to get the lines of the cels? In jupyter python I only run _ih[line_number], I need it for Printing the line near the Jacoco Coverage you can see the full code here.
To quickly replicate: