ruby and java

R

Ruben Herman

I have a .jar file and want to use some methods form this jar file in
ruby without using jruby.
can someone help me?
thank you!
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

I have a .jar file and want to use some methods form this jar file in
ruby without using jruby.
can someone help me?
thank you!
Why don't you want to use JRuby? It's really straightforward, you can
basically interact with the Java as if it were Ruby (except sometimes you
have to help it figure out the typing).
 
R

Ruben Herman

Josh Cheek wrote in post #955656:
Why don't you want to use JRuby? It's really straightforward, you can
basically interact with the Java as if it were Ruby (except sometimes
you
have to help it figure out the typing).


I don't want to use Jruby because my ruby code will be use by a tool
that is based on ruby not jruby (sorry for my english).
 
A

arton

Hi,

I believe RJB (Ruby Java Bridge) is for you.
http://rubyforge.org/projects/rjb/
Rjb is Ruby extension library for 1.8.x or 1.9.1 or later and Rubinius.
And it was tested on OS X, some Linux, Windows with JSE 1.6.
But it has restriction for multithreading and may not run with Swing,
AWT etc. So if you need GUI, jruby is your choice.

You can find some document on http://www.artonx.org/collabo/backyard/?RubyJavaBridge

- easy start:
set JAVA_HOME environment variable to your JDK installed directory.
gem install rjb

script sample)

require 'rjb'
require 'rjbextension' # for direct jar load

require 'full-path-name-of-jarfile.jar'

Rjb::load # load JVM in Ruby's
FooBar = Rjb::import('Foo.Bar.YourClass') # load Class into FooBar
foobar = FooBar.new # instantiate from the class
foobar.call_instance_method(and arguments) # invoke it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top