Using Java resources in JRuby


I was wondering whether some of you could comment or give me some
about how exactly the JRuby runtime is dealing with the Java resources
a particular JRuby script needs and uses.

Imagine, that i have a JRuby script, which depends on a particular Java
library, packed as a jar archive. Usually, i will put a ‘require’
in the beginning of the script, giving the path to the jar file on the
system. Thus, the JRuby script declares its dependency on some Java
resources. Then, i can use classes from the library in my JRuby code.

But what would happen if i comment the ‘require’ statement ? Will the
interpreter signal an error when it reaches the first line of the
which actually makes use of the library ?

The very natural answer is ‘yes, it will yield an error’.

However, i have managed to get a particular JRuby set up running, in
i have commented my ‘require’ statement, moved the jar file to some very
different location, and i have made the jar visible to the class loader
my application. And it works ! And since i am sure that my JRuby script
actually needs the jar, this means that somehow the JRuby runtime ‘sees’
jar file and finds it.

I know that when JRuby needs some resource, it searches some specific
system locations (and also searches the paths defined by ‘require’
statements), but is there anything else that it also does ? How can be
set up explained - why has the jar been found ?

Kindest Regards,

View this message in context:
Sent from the JRuby - User mailing list archive at

To unsubscribe from this list, please visit: