Forum: JRuby How to find my locally installed Gems in my jar (SOLVED)

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.
3a81ced4012650ca2004c9bff7b18202?d=identicon&s=25 Ronald F. (rovf)
on 2015-12-22 17:59
(Crossposting note: I've now posted this question at
too, after not having received any response here)

I'm on Windows, with JRuby 1.7.23 (but I think this doesn't matter for
this question).

My project directory has the following subdirectories:

- javas (contains the Java source files)
- rubies (contains the Ruby source files)
- gem (contains my gems)

That is, my gem directory is *not* a standard place.

I install the gems with

  jruby -S gem install GEMNAME --install-dir ./gem

and set the environment variable GEM_HOME to my ./gem directory

If I had a pure JRuby application, it would find my installed gems. The
problem is that it is a mixed Java application. I'm creating my jar file
like this:

  jar cvfm app.jar -C . Main.class javas\*.class rubies

which, as I can see, nicely packs my gems into the jar file. When I run
my application with

  java -cp c:\jruby\jruby.jar;app.jar Main

I get an exception when I require one of my installed gems, which is not
surprising, because GEM_HOME doesn't have any meaning when the
application is run from the jar file, does it?

What is the best approach in this case? Should I explicitly manipulate
the $LOAD_PATH, and if yes, how?


Problem solved! For the solution, have a look at the Stackoverflow link
mentioned above.
This topic is locked and can not be replied to.