Forum: JRuby Ruby program runs well when executing in file system, keeps silent when run from jar file

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 2015-11-24 15:50
jruby (2.2.2) 2015-11-12 b9fb7aa Java HotSpot(TM) 64-Bit Server
VM 24.79-b02 on 1.7.0_79-b15 +jit [Windows 7-amd64]

Main program in Java, calling JRuby code via RedBridge Core. Java
classes are in a Jar-File.

This setup works, as long I don't insist that the Ruby code is also
executed from within the Jar-File, instead of being searched inside the
file system.

First, here is the WORKING case:

// My main program (
import vp.VP;
public class Jmain {
  public static void main(String[] args){
    System.out.println("Jmain started");
    VP vp = new vp.VP();
    System.out.println("vp instance created");;
    System.out.println("Jmain terminating");

// My VP class (
package vp;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.RubyObject;
import org.jruby.embed.ScriptingContainer;
import org.jruby.embed.LocalContextScope;
import java.util.*;
public class VP {
  private ScriptingContainer container;
  public VP() {
    container = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
  public void run() {
    RubyObject asahi =
    System.out.println("scriptlet executed");

# My Ruby program rbsrc/bridge.rb
puts "Entering bridge" # Just to see what's going on
File.write("out.txt","This file was created by bridge.rb\n")
# ... rest of the code not shown

:: I put everything into a jar file, including the Ruby files
:: (although I don't need them there yet).
jar cvfm jars\vp.jar .... rbsrc

:: The program is executed like this:
java -cp c:\jruby-\lib\jruby.jar;jars\vp.jar Jmain

I see the result of all the println statements, and the file out.txt is

Now for the NON-WORKING case:

In the whole setting, I change ONLY ONE line: The invocation of
bridge.rb becomes

    RubyObject asahi =

That is, I replace RELATIVE by CLASSPATH, and drop the "rbsrc/". When I
run this, I get no error message, I get the output of all the println
statements, BUT I don't see the output of the 'puts' statement, nor is
the file out.txt created!

Note that bridge.rb seems to be loaded correctly (if I change bridge.rb
to a different name, I get an exception), but it doesn't seem to be

How come?
Ronald F. (Guest)
on 2015-12-11 16:40
This topic is locked and can not be replied to.