Search code examples
javarubyrjb

Ruby 32 bit with java 64 bit on Windows


I am using java bridge (for Stanford-Core-NLP) with ruby, and its seems that jrb can not work while Ruby is 32 bit (193) and Java is 64 bit, on a Windows machine.

Could it be? is there any solution, better than installing Ruby 64 (not supported by many gems)? I must use Java 64 to support 4giga Java applications.

thanks this is the error msg:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `load': can't create Java VM (RuntimeError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `init_rjb'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:38:in `load_jar_rjb'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:27:in `load'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:63:in `load_jar'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:71:in `block in load_default_jars'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `load_default_jars'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:55:in `bind'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.5.1/lib/Stanford-Core-NLP.rb:125:in `bind'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/stanford-core-nlp-0.5.1/lib/Stanford-Core-NLP.rb:140:in `load'

Solution

  • I'm pretty sure that the answer is No.

    The reason is that (generally speaking) you cannot mix 32bit and 64bit code in the same executing program. There is no way for a non-privileged (i.e. "user-mode") program to switch the CPU between different addressing modes.

    Various other "calls for help" for Ruby + Java + RJB on other forums seem to support this ...