[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Calling a Java Class

Ike

10/20/2006 12:17:00 AM

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


9 Answers

snacktime

10/20/2006 12:34:00 AM

0

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

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

David Vallner

10/20/2006 12:56:00 AM

0

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

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

David Vallner

Jared Richardson

10/20/2006 2:46:00 AM

0

If you'll forgive me posting my own blog entry

http://www.jaredrichardson.net/blog/2006/0...

It sounds like you need to look at the Ruby Bridge project
(http://rjb.ruby...) and the Yet Another Java Bridge project
(http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/cgi-bin/fw/wiki.cgi...).

Jared
http://jaredrich...

--

"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
>


user@domain.invalid

10/20/2006 9:47:00 AM

0

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.
>

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)

Ike

10/20/2006 2:19:00 PM

0

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

-Ike


Charles Oliver Nutter

10/21/2006 3:24:00 PM

0

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

Ike

10/22/2006 2:16:00 AM

0

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.



Charles Oliver Nutter

10/22/2006 8:27:00 AM

0

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 :) 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

David Vallner

10/23/2006 12:41:00 AM

0

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 :) 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