Forum: JRuby Accessing from Java a variable fom the JRuby script top-level environment

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ronald F. (Guest)
on 2016-01-05 12:27
(Crossposting note: This question has been posted also to the JRuby
mailing list 16 days before, but hasn't produced any answer so far).

jruby 1.7.23 (1.9.3p551) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit
Server VM 1.7.0_79-b15 +jit [Windows 7-amd64]

I run a scriptlet in my scripting container like this:

(RubyObject) ro =

where 'container' is of type ScriptingContainer. The "local variable
behaviour" is set to "transient".

The file example.rb contains:


I can retrieve from the Java side the value 'zzz' via the variable 'ro',
because it is explicitly returned from runScriptlet.

I can also retrieve the value of the global variable $bar using


Is there a way to retrieve the value of the toplevel variable foo?
container.get("foo") returns the null pointer.  I also tried to change
the local variable behaviour to "persistent", but still same result.
This topic is locked and can not be replied to.