Forum: JRuby Include net/ssh gems to jar file

Posted by Khirod Patra (khirodjruby)
on 2012-06-20 09:26
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
Posted by Charles Nutter (headius)
on 2012-06-20 16:05
(Received via mailing list)
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
Posted by Charles Nutter (headius)
on 2012-06-20 16:12
(Received via mailing list)
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
Posted by Khirod Patra (khirodjruby)
on 2012-06-21 07:52
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
Posted by Khirod Patra (khirodjruby)
on 2012-06-21 13:14
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:in 
`require'
        from (irb):9:in `evaluate'
        from org/jruby/RubyKernel.java:1083:in `eval'
        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:in 
`signal_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:in `loop'
        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: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:71:in 
`start'
        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:70:in 
`start'
        from E:/jruby-1.6.7.2/bin/jirb:13:in `(root)'
irb(main):010:0>


-Khirod
Posted by Robin McKay (robin2)
on 2012-06-22 09:58
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.
Posted by Khirod Patra (khirodjruby)
on 2012-06-22 12:22
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.