Export existing Java Objects to a JShell?

Kevin Walls kevin.walls at oracle.com
Wed Nov 16 10:52:50 UTC 2016


Hi kulla-dev,

I am looking for a way to expose an existing Java Object to code running 
in a JShell which a Java app created.

I created a JShell which runs in the same JVM as the controlling class:

JShell.Builder builder = 
JShell.builder().executionEngine(LocalExecutionControl.create());
jshell = builder.build();

That works.  Now, I want to populate a variable such that the script 
code can access it by name.  I realise a JShell is not a ScriptEngine, 
but I am looking for an equivalent of "scriptEngine.put(name, value)".  
Any suggestions? (and apologies if I missed something obvious)

Many thanks
Kevin Walls



More information about the kulla-dev mailing list