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

jruby (2.2.2) 2015-11-12 b9fb7aa Java HotSpot™ 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?

For a solution, see

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs