Include net/ssh gems to jar file

Hi,

I want to include net/ssh gems to the main jar file in jruby. So that at
client side it does not required to install net/ssh gems.

Please guide me how I can do it in my project. I am using netbeans as
editor.

Thanks
Khirod

I believe there are JRuby wiki articles about this, but there’s a couple
ways:

  • vendor the gem contents yourself and pack all that plus JRuby into a
    jar
    manually
  • use a tool that does mostly the same thing, like Warbler or Rawr
  • Charlie

I believe there are JRuby wiki articles about this, but there’s a couple
ways:

  • vendor the gem contents yourself and pack all that plus JRuby into a
    jar
    manually
  • use a tool that does mostly the same thing, like Warbler or Rawr
  • Charlie

Thanks Charlie for your response.

I tried to create jar for net-ssh gems. I followed the below steps.

java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./net-ssh net-ssh

jar -cf net-ssh-gems.jar net-ssh .

doubt here : How can I use this jar file in my program. and how can it
get the dependencies required for net-ssh.

  • Khirod

My Last attempt command are follows :

jruby -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .
java -jar jruby-complete-1.6.7.2.jar -S gem list

*** LOCAL GEMS ***

jruby-pageant (1.1.1 java)
net-ssh (2.5.2)
rake (0.8.7)
sources (0.0.1)

So here it show the gems net-ssh, but… when I checked the the gems
through irb net-ssh throws error does not exists i.e.

irb(main):006:0> require ‘rubygems’
=> true
irb(main):007:0> require ‘rake’
=> true
irb(main):008:0> require ‘sources’
=> true
irb(main):009:0> require ‘net-ssh’
LoadError: no such file to load – net-ssh
from org/jruby/RubyKernel.java:1033:in require' from file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:inrequire’
from (irb):9:in evaluate' from org/jruby/RubyKernel.java:1083:ineval’
from
file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:158:in
eval_input' from file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:271:insignal_status’
from
file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:155:in
eval_input' from org/jruby/RubyKernel.java:1410:inloop’
from org/jruby/RubyKernel.java:1183:in catch' from file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:154:ineval_input’
from
file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:71:in
start' from org/jruby/RubyKernel.java:1183:incatch’
from
file:/E:/jruby-1.6.7.2/lib/gems/jruby-complete-1.6.7.2.jar!/META-INF/jruby.home/lib/ruby/1.8/irb.rb:70:in
start' from E:/jruby-1.6.7.2/bin/jirb:13:in(root)’
irb(main):010:0>

-Khirod

Khirod Patra wrote in post #1065293:

Hi,

I want to include net/ssh gems to the main jar file in jruby. So that at
client side it does not required to install net/ssh gems.

Please guide me how I can do it in my project. I am using netbeans as
editor.

Thanks
Khirod

Perhaps it would be easier to work with the “normal” version of JRuby
rather than the .jar version. If you use the normal version “gem install
xxx” puts the gems within the JRuby directory structure. You can then
.zip the whole lot and distribute that. As far as I can see the zipped
version will be as small as the .jar version.

I solved it :

The problem was with the dependencies

for net-ssh it required :
jruby-openssl
jruby-peagant

So finally :

jruby -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri
jruby -S gem install -i ./jruby-openssl jruby-openssl --no-rdoc --no-ri
jruby -S gem install -i ./jruby-peagant jruby-peagant --no-rdoc --no-ri

jar uf jruby-complete-1.6.7.2.jar -C jruby-openssl.
jar uf jruby-complete-1.6.7.2.jar -C jruby-peagant .
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .

java -jar jruby-complete-1.6.7.2.jar -S gem list

java -jar jruby-complete-1.6.7.2.jar -S irb

irb> require ‘rubygems’
=>true
irb> require ‘net/ssh’
=>true

That’s It …

-Khirod