Search code examples
javarubyrubygemsjruby

Creating a gem using Jruby and not Ruby


So I was successful in writing a jruby file and reading from a jar file.

I also created a seperate Ruby gem, installed it and used it successfully.

I would like to write a gem using Jruby (and not ruby). When I did try to do so and after installing the gem, it gave me the following error:

  `require': cannot load such file -- java (LoadError)

Is there a specific way to write a gem using jruby that is different from the way to write a gem usig ruby? If so, please direct me to a useful tutorial that helps me create a gem using jruby

thank you.

EDIT:

I added the following to the jruby_gem.gemspec file

s.platform = 'java'

Built the gem using the command:

gem build jruby_gem.gemspec

and installed it using the command:

gem install jruby_gem-0.0.0

And when I tried to run it using the commands:

irb
require 'jrubt_gem'

I still got the same error.


Solution

  • Using the following commands

    jruby -S gem build jruby_gem.gemspecs

    and

    jruby -S gem install jruby_gem-0.0.0-java.gem

    worked for me, finally.