Sample code for including C++ or java classes in ruby

Hi,
I just started learing ruby, and I have difficulties
in invoking/uses C++ and Java classes inside ruby.

Can anyone send me a sample code for using C++ or java
classes in ruby?
Thanks alot

···


Mamoun


Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

Hi,

Welcome to Ruby. In my opinion, it is usually not the first step to
invoke/use C++ and Java classes for people in learning Ruby. If the
question is just whether it is possible, I think the answer is definitely
yes.

If you really want to use some existing library of C++ or Java classes
from Ruby, probably it is a good idea to check first whether some people
have already done the work so that you can just include the extension and
you don’t need to know the underlying details.

However, if you want to invoke your own C++ and Java classes from Ruby, it
is in general not a trivial matter. Some pointers are:

  • If you want to see how to call C code from Ruby, you can scan the
    “Extending Ruby” Chapter of the “Programming Ruby” book.
  • If you want to use C++ classes from Ruby, you can scan the SWIG web
    site.
  • If you want to use Java classes from Ruby, you can scan the JRuby web
    site.

Regards,

Bill

···

===========================================================================
Mamoun Awad mxawad2000@yahoo.com wrote:

Hi,
I just started learing ruby, and I have difficulties
in invoking/uses C++ and Java classes inside ruby.

Can anyone send me a sample code for using C++ or java
classes in ruby?
Thanks alot

Mamoun