[jruby] Scriptlet not looked up in Jar file, but always in file system!!!

changepoint_advi.fischer at extaccount.com changepoint_advi.fischer at extaccount.com
Fri Jan 8 00:40:01 JST 2016

(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 have my Java classes and my Ruby sources all in a Jar file (i.e. I would like to deliver everythin in a jar), and I call my scriptlet with

 ScriptingContainer container = new ScriptingContainer(LocalContextScope.CONCURRENT);

However, myscriptlet.rb is always loaded from the file system, not from the Jar file. I can verify this by copying my Jar file to a different directory.  Running the application from the original works fine, but running it from the copied location, I get an exception:

   java.io.FileNotFoundException: C:\tmp\ctest\rubyapp\myscriptlet.rb

From the path printed in the error message, I can see that the scriptlet is searched relative to the working directory (C:\tmp\ctest).

My scriptlet is included in the Jar like this:

  jar myapp.jar .... foo\x.class foo\y.class rubyapp\myscriptlet.rb

I tried to run my application in two different ways (but both having the same problem):

(1) Using 2 Jar files (one for JRuby itself, one for my application), and -cp

java -cp jruby-complete-1.7.23.jar;myapp.jar MainClass

(2) Combining the JRuby jar file AND my own myapp.jar file into a single Jar file, and running it as

   java -jar combined.jar

What am I doing wrong?

If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support.

More information about the JRuby mailing list