On Tue, Sep 27, 2011 at 8:23 AM, Eduardo R. [email protected]
wrote:
Is it possible to pass to Jirb a reference to that instance ?
It’s definitely possible, though the specifics depend upon which
embedding API you’re using.
Here’s an example I have using the JSR 223 embedding approach:
Note that after putting this value in the scope with the name “foo”,
it’s available within Ruby code as a global variable, so must be
accessed as $foo.
On Tue, Sep 27, 2011 at 9:34 AM, Anthony J. [email protected]
wrote:
Is it possible to pass to Jirb a reference to that instance ?
It’s definitely possible, though the specifics depend upon which
embedding API you’re using.
Here’s an example I have using the JSR 223 embedding approach:
Cool!
Note that after putting this value in the scope with the name “foo”,
it’s available within Ruby code as a global variable, so must be
accessed as $foo.
Eduardo:
You can choose to use ScriptingContainer. I guess you don’t use other
languages from the same Java code. In such a case, ScriptingContainer
would be easier to use.
Thanks for the replies but I still did not managed to make it work.
I didn’t explain exactly what I am trying to accomplish.
I found an example based on java class TextAreaReadline.
This shows a console inside a Java Swing JFrame.
From the example I only have two class instances available: Ruby and
RubyInstanceConfig. From the Javadoc, I could not interpret if some of
its method could help me.
Without using JSR 223 and BSF approaches, how do I manage to pass Java
objects to the TextAreaReadline “console” ?
I found “org.jruby.javasupport.JavaEmbedUtils.java” class also. Does it
help?
You can do like above, but is not recommended.
Do you know JRuby has embedding API? If not, RedBridge · jruby/jruby Wiki · GitHub will help you how to do
that.