[rjb-users] Extending a Java class

rjb-users at rubyforge.org rjb-users at rubyforge.org
Tue Oct 31 01:09:17 EST 2006

Hi Arton,

I was wondering how to extend a Java class with RJB. I
saw in the documentation how to bind a Java interface
to a Ruby class, but can I extend a Java class with
Ruby? Here's an example of what I've tried:

require 'rubygems'
require_gem 'rjb'
require 'rjb'

Vector=Rjb::import 'java.util.Vector'

class Test < Vector.class
  def initialize
  def test_vector
    puts "it worked"

t=Test.new # => TypeError: allocator undefined for

I get a TypeError with the above code. If I try to
extend directly form Vector rather than Vector.class,
I get:

TypeError: superclass must be a Class

Any ideas?


Richard Apodaca
Blog: http://depth-first.com

Get your email and see which of your friends are online - Right on the New Yahoo.com 

More information about the rjb-users mailing list