Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 549
  • Last Modified:

ruby error while running a java class from ruby

This is the application while running from ruby this class i am getting this error

require "java"

include_class "java.util.TreeSet"
include_class "com.example.CallMe"
include_class "com.example.ISpeaker"

puts "Hello from ruby"
set = TreeSet.new
set.add "foo"
set.add "Bar"
set.add "baz"
set.each { |v| puts "value: #{v}" }

cm = CallMe.new
cm.hello
$globalCM.hello

class CallJava
  include ISpeaker
  def initialize
    super
    @count = 0
  end

  def say(msg)
    puts "Ruby saying #{msg}"
  end
 
  def addOne(from)
#    m.synchronize {
      @count += 1
      puts "Now got #@count from #{from}"
#    }
  end
end

while running a java application from ruby i am getting this error

C:\>ruby c:\Ruby193\call_java.rb
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require':
cannot load such file -- java (LoadError)
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n `require'
        from c:/Ruby193/call_java.rb:1:in `<main>'

C:\>
0
roy_sanu
Asked:
roy_sanu
1 Solution
 
fridomCommented:
I doubt you can use Matz Ruby with Java? I was thinking this just works for JRuby....
This suggests that I may be right:
http://rjb.rubyforge.org/
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now