In two way you can add Ruby Gems to your JRuby application.
Case 1: In this case we will take the gems for ssh connections i.e. net-ssh. So what ever the gems you want to add in your application , 1st check the required dependencies for that gems. in this case for net-ssh we required
1)jruby-openssl
2)jruby-pageant
1)download the jruby-complete-XXXX.jar file . check with below link for the respective versions.
http://jruby.org/download
you can create a jruby-complete.jar file from source too.
a) download the jruby source from http://jruby.org/download
Ex:- E:\jruby-src-1.6.7.2.zip
b) unzip it to any local directory
Ex:- unzip jruby-src-1.6.7.2.zip
It will create a directory jruby-1.6.7.2
c) download and unzip ant if ant is not on your system http://ant.apache.org/bindownload.cgi
d) set the ANT_HOME and PATH for the ant.
e) change current directory to the unzip jruby source directory
cd E:\jruby-1.6.7.2
f) ant jruby-complete
It will create a jruby-complete.jar file which is same as if you follow to download it from the repository link http://jruby.org/download
Let your final jruby-complete.jar file in E:\jruby\jruby-complete.jar
2) Let download and get the required gems . use the following command to do so
To get jruby-openssl:
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-openssl jruby-openssl --no-rdoc --no-ri
To get jruby-pageant:
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-pageant jruby-pageant --no-rdoc --no-ri
To Get net-ssh :
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri
Now you have all the gems in your current directory i.e. E:\jruby
3) Let push these gems to the jruby-complete.jar file
jar uf jruby-complete-1.6.7.2.jar -C jruby-openssl .
jar uf jruby-complete-1.6.7.2.jar -C jruby-pageant .
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .
4) Lets check if the gems pushed successfully or not
java -jar jruby-complete-1.6.7.2.jar -S gem list
*** LOCAL GEMS ***
bouncy-castle-java (1.5.0146.1)
jruby-openssl (0.7.7)
jruby-pageant (1.1.1 java)
net-ssh (2.5.2)
rake (0.8.7)
sources (0.0.1)
5) Let's check if the gems are loading through require or not
java -jar jruby-complete-1.6.7.2.jar -S irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/ssh'
=> true
irb(main):003:0> exit
-------------------------------End of Case 1--------------------------------------------------------------------
NOTE : you can install and push the gems in a single command also , just use them in the same command syntax with space..
--------------------------------------------------------------------------------------------------------------------
WOW that's it . now all your gems in your jar file.
case 2 is the traditional one.
1) follow the same step no 1 from Case1
2) now you have the jruby-complete.jar file . and your current directory is
E:\jruby
create a directory structure E:\jruby\lib\gems\1.8
Note : Here I used the above path for a separate the gems directory . So it is completely depends on you how you manage your path.
The above command will install all the required gems described in the command in the defined path . So here you can replace your destination path
4) Set the GEM_PATH
set GEM_PATH=E:\jruby\lib\gems\1.8
In Linux : export GEM_PATH=`pwd`/lib/gems/1.8
5) Now follow the Steps No 4 and 5 from Case 1 to get the result.
That's It
------------------------------------------End of Case 2--------------------------------------------------
- Khirod
Case 1: In this case we will take the gems for ssh connections i.e. net-ssh. So what ever the gems you want to add in your application , 1st check the required dependencies for that gems. in this case for net-ssh we required
1)jruby-openssl
2)jruby-pageant
Steps:: Case 1:-
1)download the jruby-complete-XXXX.jar file . check with below link for the respective versions.
http://jruby.org/download
you can create a jruby-complete.jar file from source too.
a) download the jruby source from http://jruby.org/download
Ex:- E:\jruby-src-1.6.7.2.zip
b) unzip it to any local directory
Ex:- unzip jruby-src-1.6.7.2.zip
It will create a directory jruby-1.6.7.2
c) download and unzip ant if ant is not on your system http://ant.apache.org/bindownload.cgi
d) set the ANT_HOME and PATH for the ant.
e) change current directory to the unzip jruby source directory
cd E:\jruby-1.6.7.2
f) ant jruby-complete
It will create a jruby-complete.jar file which is same as if you follow to download it from the repository link http://jruby.org/download
Let your final jruby-complete.jar file in E:\jruby\jruby-complete.jar
2) Let download and get the required gems . use the following command to do so
To get jruby-openssl:
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-openssl jruby-openssl --no-rdoc --no-ri
To get jruby-pageant:
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./jruby-pageant jruby-pageant --no-rdoc --no-ri
To Get net-ssh :
java -jar jruby-complete-1.6.7.2.jar -S gem install -i ./net-ssh net-ssh --no-rdoc --no-ri
Now you have all the gems in your current directory i.e. E:\jruby
3) Let push these gems to the jruby-complete.jar file
jar uf jruby-complete-1.6.7.2.jar -C jruby-openssl .
jar uf jruby-complete-1.6.7.2.jar -C jruby-pageant .
jar uf jruby-complete-1.6.7.2.jar -C net-ssh .
4) Lets check if the gems pushed successfully or not
java -jar jruby-complete-1.6.7.2.jar -S gem list
*** LOCAL GEMS ***
bouncy-castle-java (1.5.0146.1)
jruby-openssl (0.7.7)
jruby-pageant (1.1.1 java)
net-ssh (2.5.2)
rake (0.8.7)
sources (0.0.1)
5) Let's check if the gems are loading through require or not
java -jar jruby-complete-1.6.7.2.jar -S irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'net/ssh'
=> true
irb(main):003:0> exit
-------------------------------End of Case 1--------------------------------------------------------------------
NOTE : you can install and push the gems in a single command also , just use them in the same command syntax with space..
--------------------------------------------------------------------------------------------------------------------
WOW that's it . now all your gems in your jar file.
Steps - Case 2:
case 2 is the traditional one.
1) follow the same step no 1 from Case1
2) now you have the jruby-complete.jar file . and your current directory is
E:\jruby
create a directory structure E:\jruby\lib\gems\1.8
Note : Here I used the above path for a separate the gems directory . So it is completely depends on you how you manage your path.
3) java -jar jruby-complete.jar -S install jruby-openssl jruby-pageant net-ssh --no-ri --no-rdoc -i lib/gems/1.8
The above command will install all the required gems described in the command in the defined path . So here you can replace your destination path
4) Set the GEM_PATH
set GEM_PATH=E:\jruby\lib\gems\1.8
In Linux : export GEM_PATH=`pwd`/lib/gems/1.8
5) Now follow the Steps No 4 and 5 from Case 1 to get the result.
That's It
------------------------------------------End of Case 2--------------------------------------------------
- Khirod
No comments:
Post a Comment