Solved

ruby error while running a java class from ruby

Posted on 2012-12-25
1
531 Views
Last Modified: 2013-01-12
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
Comment
Question by:roy_sanu
1 Comment
 
LVL 24

Accepted Solution

by:
fridom earned 500 total points
ID: 38769839
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Ruby Gems Passenger Error 13 1,065
Choosing a Server-Side Scripting Language - Criterion 2 4 337
Upgrade Ruby from 1.8.7 to 1.9.2-p320 7 328
Script that doesn't print duplicate lines 2 216
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question