Scriptengine redirect

I recently encountered a strange problem when trying to redirect the
ScriptEngine output for my ruby session. It seems that no matter what I
pass in to my ScriptEngine, it always prints to stdout and stderr. I
found this post, but it says it’s fixed.

https://scripting.dev.java.net/issues/show_bug.cgi?id=8

scriptContext.setWriter(outWriter);
scriptContext.setErrorWriter(errWriter);

ruby.setContext(scriptContext);
ruby.eval(…)

Yet it still goes to stdout every time. Has this issue truly been
resolved?

Hi,

On Sat, Dec 11, 2010 at 12:37 AM, Josh S. [email protected]
wrote:

ruby.setContext(scriptContext);
ruby.eval(…)

Yet it still goes to stdout every time. Has this issue truly been
resolved?

What version of JRuby are you using? JSR223 implementation was
rewritten and has been included in JRuby since 1.4.0. If you are using
JRuby 1.4.x or 1.5.x, remove jruby-engine.jar from your classpath.
Then, above code should work.

-Yoko

Yoko H. wrote in post #967834:

Hi,

On Sat, Dec 11, 2010 at 12:37 AM, Josh S. [email protected]
wrote:

ruby.setContext(scriptContext);
ruby.eval(…)

Yet it still goes to stdout every time. Has this issue truly been
resolved?

What version of JRuby are you using? JSR223 implementation was
rewritten and has been included in JRuby since 1.4.0. If you are using
JRuby 1.4.x or 1.5.x, remove jruby-engine.jar from your classpath.
Then, above code should work.

I just added the jruby-complete-1.5.6.jar to my classpath. Is there a
link to a smaller distribution I could add there? I just downloaded the
complete jar recently from the jruby website.

http://jruby.org.s3.amazonaws.com/downloads/1.5.6/jruby-complete-1.5.6.jar

On Dec 15, 2010, at 13:28 , Yoko H. wrote:

resolved?
http://jruby.org.s3.amazonaws.com/downloads/1.5.6/jruby-complete-1.5.6.jar

I’m not sure you actually need jruby-complete.jar since it depends on
how you use it. But, usually people download JRuby from jruby.org. The
archive downloaded from jruby.org has jruby.jar, which is smaller than
jruby-complete.jar.

The complete jar is “complete” because it contains the Ruby standard
library + Rubygems.

This one is the core JRuby classes and is a few megs lighter, if that
helps.

http://repo2.maven.org/maven2/org/jruby/jruby/1.5.6/jruby-1.5.6.jar

/Nick

On Sat, Dec 11, 2010 at 4:35 PM, Josh S. [email protected]
wrote:

What version of JRuby are you using? JSR223 implementation was
rewritten and has been included in JRuby since 1.4.0. If you are using
JRuby 1.4.x or 1.5.x, remove jruby-engine.jar from your classpath.
Then, above code should work.

I just added the jruby-complete-1.5.6.jar to my classpath. Is there a
link to a smaller distribution I could add there? I just downloaded the
complete jar recently from the jruby website.

http://jruby.org.s3.amazonaws.com/downloads/1.5.6/jruby-complete-1.5.6.jar

I’m not sure you actually need jruby-complete.jar since it depends on
how you use it. But, usually people download JRuby from jruby.org. The
archive downloaded from jruby.org has jruby.jar, which is smaller than
jruby-complete.jar.

-Yoko

The complete jar is “complete” because it contains the Ruby standard
library + Rubygems.

This one is the core JRuby classes and is a few megs lighter, if that
helps.

http://repo2.maven.org/maven2/org/jruby/jruby/1.5.6/jruby-1.5.6.jar

I’ve tried this one as well. I need some of those gems like ‘set’ and
‘singleton’. Are you guys saying I can’t use these libraries because
the ruby version doesn’t handle redirection correctly?