Gives the RubyGems environment:
- RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.9.2 (2010-12-25 patchlevel 136) [i386-mingw32] - INSTALLATION DIRECTORY: C:/Ruby192/lib/ruby/gems/1.9.1 - RUBY EXECUTABLE: C:/Ruby192/bin/ruby.exe - EXECUTABLE DIRECTORY: C:/Ruby192/bin - RUBYGEMS PLATFORMS: - ruby - x86-mingw32
Try Installing Rjb
Set environment variable “JAVA_HOME” to JDK’s home directory. If you do not have VC (which I dislike for no reasons) on your Windows box, as mentioned in an earlier post, you will probably encounter the following error message
ERROR: Error installing rjb: ERROR: Failed to build gem native extension.
gem install rjb
Do not try alternatively, using option “–platform x86-mswin32,” which requires VC for rjb to function correctly.
Then you can find the following if you endeavor to see between the dreadful lines:
In file included from load.c:31:0: jniwrap.h:24:19: error: 'long long long' is too long for GCC
Understand the Error Message
Open file “jniwrap.h” in “Path-to-your-rjb-1.3.4-Source\ext” where “Path-to-your-rjb-1.3.4-Source” is the rjb directory created by rubygems. It should look like “C:\Ruby192\lib\ruby\gems\1.9.1\gems\rjb-1.3.4.” Then locate the following line of code
typedef long long __int64;
That is the source of the error. As to 64-bit integer types, it seems that neither “__int64″ nor “long long” is a standard way for C++ compilers, while C99 supports “long long”.
In the file “jniwrap.h”, simply comment out this line or replace it with the following line should do the trick
typedef long long long64;
You will need MinGW installed for recompiling rjb. (Guess Cygwin should serve this purpose too.) Get automated installer for MinGW and MSYS from here. Then recompile rjb manually under directory “Path-to-your-rjb-1.3.4-Source/ext”:
cd "Path-to-your-rjb-1.3.4-Source/ext" make make all make install
cd .. gem spec ../../cache/rjb-1.3.4.gem --ruby > ../../specifications/rjb-1.3.4.gemspec
It may still cry a bit with the following warning. Well, just let it go.
WARNING: File 'C:/Ruby192/lib/ruby/gems/1.9.1/specifications/rjb-1.3.4.gemspec' does not evaluate to a gem specification
You can see that rjb-1.3.4 is now listed in the local gem list by doing
gem list --local
Run all the tests and samples provided by rjb-1.3.4. It should all go through
cd test ruby test.rb ruby gctest.rb ruby exttest.rb cd ../samples ruby filechooser.rb
Say hello to Rjb? Save the following as hellorjb.rb
require 'rjb' out = Rjb::import('java.lang.System').out out.print('Hello Rjb from ') p out._classname
Just run it