Search code examples
rubypathjvmnlprjb

Ruby RJB can't create Java VM error


I've seen this question asked a few times but no repsonses have worked for me. I've tried several versions of rjb, several jre versions..No matter what I try, when trying to use the rjb gem i get the following error:

DL is deprecated, please use Fiddle
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `load': can't create Java VM (RuntimeError)

I have JAVA_Home in my path. I am just using simple code to test rjb as I really just need this to work so the stanford open nlp gem will work for me.

Any explanations? Might help some other poor souls out there...I am running on windows if that helps

UPDATE: tried the following in the command line to troubleshoot

 ruby -d -rubygems -rrjb -e 'Rjb::load'
Exception `LoadError' at c:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems.rb:1203 - cannot load such file -- rubygems/defaults/ruby
Exception `LoadError' at c:/RailsInstaller/Ruby2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55 - cannot load such file -- rjb
Exception `Fiddle::DLError' at c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/fiddle.rb:46 - No such file or directory
DL is deprecated, please use Fiddle
Exception `DL::DLError' at -e:1 - No such file or directory
Exception `Fiddle::DLError' at c:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/fiddle.rb:46 - No such file or directory
Exception `DL::DLError' at -e:1 - No such file or directory
Exception `RuntimeError' at -e:1 - can't create Java VM
-e:1:in `load': can't create Java VM (RuntimeError)
        from -e:1:in `<main>'

Does this mean there is an error with path or JAVA_HOME ? If so, how would I go about setting that correctly?


Solution

  • So after I finally came across a solution. rjb will only work if java and ruby are BOTH 32 bit or BOTH 64 bit. Different versions will cause the VM error.

    To solve:

    1. Find version of ruby you are running ruby -v in terminal
    2. Find version of java javac or java -v in terminal
    3. Look up if versions are 64 bit or 32 bit
    4. If different, I thought it was easier to change my version of jdk- uninstall jdk
    5. Download/install x86 (32 bit) version of jdk
    6. make sure JAVA_HOME env variable is set to the location of the jdk (may have to restart for any changes you make to take effect

    Boom- Hope this works for everyone else as well!