Calling a Java Class

Is there a way to invoke a Java class, from within Ruby, without using, say
JRuby? I am looking at getting very involved in JRuby, but just want to
check if there isn;t some alternative means within Ruby itself for doing
this.

Thanks, Ike

I believe there are one or two jni libraries for ruby, but I've never
really looked into them.

···

On 10/19/06, Ike <rxv@hotmail.com> wrote:

Is there a way to invoke a Java class, from within Ruby, without using, say
JRuby? I am looking at getting very involved in JRuby, but just want to
check if there isn;t some alternative means within Ruby itself for doing
this.

Thanks, Ike

Ike wrote:

Is there a way to invoke a Java class, from within Ruby, without using, say
JRuby?

http://rjb.rubyforge.org/ for one. Never used it, seems active -ish though.

David Vallner

If you'll forgive me posting my own blog entry

http://www.jaredrichardson.net/blog/2006/09/01/#yajb

It sounds like you need to look at the Ruby Bridge project
(http://rjb.rubyforge.org/\) and the Yet Another Java Bridge project
(Software Error).

Jared
http://jaredrichardson.net

···

--

"Ike" <rxv@hotmail.com> wrote in message
news:TzUZg.11721$Y24.7667@newsread4.news.pas.earthlink.net...

Is there a way to invoke a Java class, from within Ruby, without using,
say JRuby? I am looking at getting very involved in JRuby, but just want
to check if there isn;t some alternative means within Ruby itself for
doing this.

Thanks, Ike

You could use xml-rpc or something similar to call a java process from a ruby process...

You have to embbed your class in a java server, like Jetty (which is pretty lightweighted)

It's a good solution if your project is big enough (is worth the added work)

···

le 20/10/2006 02:16, Ike nous a dit:

Is there a way to invoke a Java class, from within Ruby, without using, say JRuby? I am looking at getting very involved in JRuby, but just want to check if there isn;t some alternative means within Ruby itself for doing this.

yeah....YAJB seems to be exactly what I am looking for. Any reason you know
if that it canot be run in Rails?

-Ike

Zouplaz wrote:

You could use xml-rpc or something similar to call a java process from a ruby process...

You have to embbed your class in a java server, like Jetty (which is pretty lightweighted)

It's a good solution if your project is big enough (is worth the added work)

Of course I need to chime in and say that although there are other options, calling a Java class is trivially easy in JRuby, so if it's simplicity you're looking for it might be the best way to go. Other options are great if you have the restriction of running only under the C implementation, but for straight Ruby-to-Java calling JRuby is the cleanest and simplest option.

···

--
Charles Oliver Nutter, JRuby Core Developer
headius@headius.com -- charles.o.nutter@sun.com
Blogging at headius.blogspot.com

I've used YAJB to power some PDF generation stuff using Apache FOP in a
rails app. Can't say I've noticed any problems, but then the app's not
exactly in high-load usage, so take what I say with a healthy pinch of salt.

···

On 20/10/06, Ike <rxv@hotmail.com> wrote:

yeah....YAJB seems to be exactly what I am looking for. Any reason you
know
if that it canot be run in Rails?

-Ike

I have to add that JRuby 0.9.1 is just amazing. This truly melds the best of
both worlds, and you guys on the JRuby team have done incredible work on
this important piece of software.

Ike wrote:

I have to add that JRuby 0.9.1 is just amazing. This truly melds the best of both worlds, and you guys on the JRuby team have done incredible work on this important piece of software.

Cool, thanks :slight_smile: And I'm sure all the previous contributors to JRuby thank you as well.

···

--
Charles Oliver Nutter, JRuby Core Developer
headius@headius.com -- charles.o.nutter@sun.com
Blogging at headius.blogspot.com

Charles Oliver Nutter wrote:

Ike wrote:

I have to add that JRuby 0.9.1 is just amazing. This truly melds the
best of both worlds, and you guys on the JRuby team have done
incredible work on this important piece of software.

Cool, thanks :slight_smile: And I'm sure all the previous contributors to JRuby
thank you as well.

Any odds the Groovy JSR gets dragged out and shot^W^W^W^W displaced by a
JRuby one? Without aiming to bash Groovy (more), I'd much prefer JRuby
for doing (Cruel and) unusual things onna JVM using DSLs instead of
first-class feature creep.

(Even if, aside from Weird Things, I follow the Beanshell Whenever
Possible policy for impedance mismatch minimisation reasons.)

Speaking of Weird Things, IntelliJ IDEA plugin anyone? Inspecting beans
during a debugger breakpoint using JRuby has a certain ring to it.
Spawning a REPL with module / project classes loaded more so. I've been
pondering getting myself a pet project of General Usefulness to toy
with, except I have no idea where I'd start with this sort of hackery
which involves touching the JVM in all the wrong places.

David Vallner