"Cannot create Java VM" error while trying to use the pearl of Ruby Java Bridge (RJB)

I am trying to implement the pearl of the Ruby Java Bridge (RJB) to talk with the JVM so that I can launch the Open-NLP stone. I have Java installed and running on Windows 8. All indications, at least I know, is that Java is installed and running. But attempts to crash RJB with the message "cannot create a Java VM." (Sometimes I get the undefined `dlopen 'method for Fiddle: Module" in other cases, which also cannot be parsed.)

At first I just installed the JDK by default. Due to my 64-bit system, this installed 64-bit Java. I was not sure whether Ruby and RJB would talk about this, so I installed a 32-bit JRE. However, the error is the same.

Is there any additional test I can run to ensure that the JVM runs outside of Ruby?

Can someone tell me what I need to do to run Windows / Ruby / RJB / JVM?

Thanks...

I am running Windows 8 with BitNami Rubystack and Ruby 1.9.3p448.

Java seems to be available according to testjava.jsp: enter image description here

This is the code, including the url where I found it:

class FiddleTry # http://devjete.wordpress.com/2011/01/31/installing-rjb-1-3-4-on-windows-7-32bit-wo-vc/ require 'rjb' out = Rjb::import('java.lang.System').out <== Line 5 is here out.print('Hello Rjb from ') p out._classname end 

Here are the error messages:

 C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:5:in `import': can't create Java VM (RuntimeError) from C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:5:in `<class:FiddleTry>' from C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:1:in `<top (required)>' from -e:1:in `load' from -e:1:in `<main>' 

I cannot find any further information on why "it is impossible to create a Java VM." It would really help if additional information was available to me. I would appreciate this information or this. Thanks...

EDIT TO ADD INFORMATION REGARDING THE REQUIREMENT OF OPEN NLP FOR RJB ...

This is the code I'm trying to run, taken from Github / Open-nlp:

 class OpenNlpSample ENV['JAVA_HOME'] = "C:/Program Files/Java/jdk1.7.0_25" if ENV['JAVA_HOME'].nil? ENV['LD_LIBRARY_PATH'] = "C:/Program Files/Java/jdk1.7.0_25/bin; C:/Program Files (x86)/Java/jre7" if ENV['LD_LIBRARY_PATH'].nil? # Load the module require 'open-nlp' gem_bin = File.join(Gem.loaded_specs['open-nlp'].full_gem_path, 'bin/') # Set an alternative path to look for the JAR files. # Default is gem bin folder. # OpenNLP.jar_path = '/path_to_jars/' # OpenNLP.jar_path = File.expand_path('../../ruby/lib/ruby/gems/1.9.1/gems/open-nlp-0.1.4/bin',__FILE__) OpenNLP.jar_path = gem_bin # Set an alternative path to look for the model files. # Default is gem bin folder. # OpenNLP.model_path = '/path_to_models/' OpenNLP.model_path = gem_bin # Pass some alternative arguments to the Java VM. # Default is ['-Xms512M', '-Xmx1024M']. # OpenNLP.jvm_args = ['-option1', '-option2'] OpenNLP.jvm_args = ['-Xms512M', '-Xmx1024M'] # Redirect VM output to log.txt OpenNLP.log_file = 'log.txt' # Set default models for a language. # OpenNLP.use :language OpenNLP.use :english =begin Examples Simple tokenizer =end OpenNLP.load sent = "The death of the poet was kept from his poems." tokenizer = OpenNLP::SimpleTokenizer.new tokens = tokenizer.tokenize(sent).to_a # => %w[The death of the poet was kept from his poems .] #Maximum entropy tokenizer, chunker and POS tagger OpenNLP.load chunker = OpenNLP::ChunkerME.new tokenizer = OpenNLP::TokenizerME.new tagger = OpenNLP::POSTaggerME.new sent = "The death of the poet was kept from his poems." tokens = tokenizer.tokenize(sent).to_a # => %w[The death of the poet was kept from his poems .] tags = tagger.tag(tokens).to_a # => %w[DT NN IN DT NN VBD VBN IN PRP$ NNS .] chunks = chunker.chunk(tokens, tags).to_a # => %w[B-NP I-NP B-PP B-NP I-NP B-VP I-VP B-PP B-NP I-NP O] #Abstract Bottom-Up Parser OpenNLP.load sent = "The death of the poet was kept from his poems." parser = OpenNLP::Parser.new parse = parser.parse(sent) parse.get_text.should eql sent parse.get_span.get_start.should eql 0 parse.get_span.get_end.should eql 46 parse.get_child_count.should eql 1 child = parse.get_children[0] child.text # => "The death of the poet was kept from his poems." child.get_child_count # => 3 child.get_head_index #=> 5 child.get_type # => "S" #Maximum Entropy Name Finder* OpenNLP.load text = File.read('./spec/sample.txt').gsub!("\n", "") tokenizer = OpenNLP::TokenizerME.new segmenter = OpenNLP::SentenceDetectorME.new ner_models = ['person', 'time', 'money'] ner_finders = ner_models.map do |model| OpenNLP::NameFinderME.new("en-ner-#{model}.bin") end sentences = segmenter.sent_detect(text) named_entities = [] sentences.each do |sentence| tokens = tokenizer.tokenize(sentence) ner_models.each_with_index do |model,i| finder = ner_finders[i] name_spans = finder.find(tokens) name_spans.each do |name_span| start = name_span.get_start stop = name_span.get_end-1 slice = tokens[start..stop].to_a named_entities << [slice, model] end end end =begin Loading specific models Just pass the name of the model file to the constructor. The gem will search for the file in the OpenNLP.model_path folder. =end OpenNLP.load tokenizer = OpenNLP::TokenizerME.new('en-token.bin') tagger = OpenNLP::POSTaggerME.new('en-pos-perceptron.bin') name_finder = OpenNLP::NameFinderME.new('en-ner-person.bin') # etc. #Loading specific classes #You may want to load specific classes from the OpenNLP library that are not loaded by default. The gem provides an API to do this: # Default base class is opennlp.tools. OpenNLP.load_class('SomeClassName') # => OpenNLP::SomeClassName # Here, we specify another base class. OpenNLP.load_class('SomeOtherClass', 'opennlp.tools.namefind') # => OpenNLP::SomeOtherClass end 

At this point in the code:

 =begin Examples Simple tokenizer =end OpenNLP.load 

The call chain is dl.rb, fiddle.rb and jar_loader.rb. jarloader.rb start line 43:

 # Load Rjb and create Java VM. def self.init_rjb ::Rjb::load(nil, self.jvm_args) set_java_logging if self.log_file end 

At this moment, I get the same error when creating the JVM. So, I returned to trying to start RJB. The error chain is as follows:

 Fast Debugger (ruby-debug-ide 0.4.17, ruby-debug-base19x 0.11.30.pre12) listens on 127.0.0.1:59488 Uncaught exception: can't create Java VM D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `load' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `init_rjb' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:38:in `load_jar_rjb' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:27:in `load' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:63:in `load_jar' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:71:in `block in load_default_jars' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `each' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `load_default_jars' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:55:in `bind' D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/open-nlp-0.1.4/lib/open-nlp.rb:14:in `load' C:/Users/Richard/RubymineProjects/Utilities/open_nlp_sample.rb:32:in `<class:OpenNlpSample>' C:/Users/Richard/RubymineProjects/Utilities/open_nlp_sample.rb:1:in `<top (required)>' 
+4
source share
1 answer

First I needed to uninstall Java x64 and install the x586 JDK for 32-bit support.

Then set JAVA_HOME as follows:

 JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_40 

and add JAVA_HOME to my path:

 %JAVA_HOME%\bin;C:\Program Files (x86)\Java\jre7\bin; 

This resolved the "unable to create Java VM" problem.

Setting $DEBUG=false or commenting out a line eliminates all other messages. In $DEBUG mode, error messages are displayed that can be detected and resolved, so they can be ignored.

After the β€œfailed to create Java VM” problem was resolved, all other error messages were of this type and therefore were false.

JetBrains support for Rubymine solved this problem for me. They are very good, especially Serge, and I recommend their products because of their support.

+6
source

Source: https://habr.com/ru/post/1502319/


All Articles