Module: Kernel

Defined in:
lib/rjb/extension.rb

Overview

Loads the JVM with the given classpath and arguments to the jre. All needed .jars should be included in classpath.

Instance Method Summary collapse

Instance Method Details

#load_jvm(jargs = []) ⇒ Object



73
74
75
76
77
# File 'lib/rjb/extension.rb', line 73

def load_jvm(jargs = [])
  return if Rjb::loaded?
  classpath = ENV['CLASSPATH'] ||= ''
  Rjb::load(classpath, jargs)
end

#require(path) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rjb/extension.rb', line 46

def require(path)
  rjb_original_require(path)
rescue LoadError
  # check that it's not a jar file
  raise unless path =~ /\.jar/

  # This will maybe use the wrong jar file from a previous version of the GEM
  # puts "LOAD PATH #{$LOAD_PATH}" 
  if File.respond_to?(:absolute_path?) && File.absolute_path?(path)
    found_path = File.exist?(path) ? '' : nil
  else
    found_path = $LOAD_PATH.reverse.find {|p| File.exist?(File.join(p, path))}
  end
  raise unless found_path

  abs_path = found_path.length == 0 ? path : File.join(found_path, path)
  # check that the file exists
  raise unless  File.exist?(abs_path)

  # try to load it using RJB
  if Rjb::loaded?
    Rjb::add_jar abs_path
  else
    Rjb::add_classpath abs_path
  end
end

#rjb_original_requireObject



44
# File 'lib/rjb/extension.rb', line 44

alias rjb_original_require require