Reputation: 793
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.
Upvotes: 0
Views: 1401
Reputation: 793
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.
Upvotes: 0
Reputation: 55888
Rubygems are a package format for general ruby code which is used by all ruby implementations, including MRI (the original C-Ruby), JRuby, Rubinius, and others.
When you use platform-specific code in your gems, e.g. Java for use in JRuby or C-Extensions for use in C-based Rubies, you have ti use the gem with the appropriate Ruby.
That means, if you want to call Java code directly in your gem, you have to use it with JRuby. If you just install and require the gem on MRI, it won't work.
Upvotes: 1