Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:11:08+00:00 2026-05-24T08:11:08+00:00

I am embedding JRuby using Red Bridge into an app and seem to have

  • 0

I am embedding JRuby using Red Bridge into an app and seem to have problems setting out and err. My tests use a PrintStream that writes to a StringBuilder, after doing some stuff with the JRuby, I then check the stuff printed to out with puts. The problem is only the first setOutput works everyting gets printed to that.

The simple sample below demonstrates the problem. It is using PrintStreams that write to different files to demonstrate the problem. Looking at your file system will show that everything goes to the first “file” when one would expect files 2 and 3 to also be written.

package XXX.jruby;

import java.io.PrintStream;

import org.jruby.embed.LocalContextScope;
import org.jruby.embed.LocalVariableBehavior;
import org.jruby.embed.ScriptingContainer;

public class JRubyShellPutsProblem {

    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 3; i++) {
            final ScriptingContainer container = new ScriptingContainer(LocalContextScope.CONCURRENT, LocalVariableBehavior.PERSISTENT);
            // container.resetWriter();
            // container.resetErrorWriter();

            final PrintStream printStream = new PrintStream("d:\\out" + i + ".txt");
            container.setOutput(printStream);
            container.setError(printStream);

            container.runScriptlet("puts \"hello" + i + "\"\n");
            printStream.flush();
            container.terminate();
        }
    }
}

I’ve tried ScriptingContainer.resetWriter but that does not work as one would expect. Sometimes stuff gets written to files 1 and 2 but nothing to 3.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:11:11+00:00Added an answer on May 24, 2026 at 8:11 am

    I changed LocalContextScope to THREADSAFE from CONCURRENT and this seemed to fix the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m embedding YouTube videos in a UIWebView for an iOS app. I’m using Method
I am embedding images into my assembly using .resx files. Upon runtime, I need
I'm considering embedding a scripting language into one of my software projects and have
I'm embedding a flash music player from Soundclick into my music website. I have
I'm working on embedding python into my C++ program using swig. At the moment
I have problem with embedding Polish fonts into PDF converted from HTML. My HTML
I know that embedding CSS styles directly into the HTML tags they affect defeats
I'm embedding a JRE in an existing C application using the invocation API, and
I'm embedding MSBuild directly into a more complex build tool. The relevant code looks
I'm embedding a Flash video into an HTML and would like the user to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.