Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Ruby and Java
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Wayne Pierce  
View profile  
 More options Jun 21 2005, 9:12 am
Newsgroups: comp.lang.ruby
From: Wayne Pierce <shalo...@gmail.com>
Date: Tue, 21 Jun 2005 22:12:26 +0900
Local: Tues, Jun 21 2005 9:12 am
Subject: Ruby and Java
I have a vendor product with Java APIs that I need to write against
and would like to use Ruby.

Does anyone have an opinion on the most reliable way to interact with
Java from Ruby?  I've seen some different projects, but can't tell if
there is any major difference between how they are implemented or
which are actively maintained.

Thanks,

Wayne


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Klemme  
View profile  
 More options Jun 21 2005, 10:40 am
Newsgroups: comp.lang.ruby
From: "Robert Klemme" <bob.n...@gmx.net>
Date: Tue, 21 Jun 2005 16:40:47 +0200
Local: Tues, Jun 21 2005 10:40 am
Subject: Re: Ruby and Java

Jean-Claude Arbaut wrote:
> On 21/06/2005 15:12, Wayne Pierce wrote:

>> I have a vendor product with Java APIs that I need to write against
>> and would like to use Ruby.

>> Does anyone have an opinion on the most reliable way to interact with
>> Java from Ruby?  I've seen some different projects, but can't tell if
>> there is any major difference between how they are implemented or
>> which are actively maintained.

> Seems ugly to me, but anyway...

+1

I'd use plain old Java.  That'll be much more hassle free and Java isn't
too bad IMHO.

> Maybe you will be able to use C or
> C++ as a common "glue code". There is also a program called SWIG,
> used to make Java, Ruby, Python, etc... work with C.

A third language in between - even uglier.  But probably the only workable
way.

Kind regards

    robert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Foreman  
View profile  
 More options Jun 21 2005, 11:08 am
Newsgroups: comp.lang.ruby
From: Jason Foreman <threeve....@gmail.com>
Date: Wed, 22 Jun 2005 00:08:37 +0900
Local: Tues, Jun 21 2005 11:08 am
Subject: Re: Ruby and Java
On 6/21/05, Wayne Pierce <shalo...@gmail.com> wrote:

> I have a vendor product with Java APIs that I need to write against
> and would like to use Ruby.

> Does anyone have an opinion on the most reliable way to interact with
> Java from Ruby?  I've seen some different projects, but can't tell if
> there is any major difference between how they are implemented or
> which are actively maintained.

> Thanks,

> Wayne

Two main options:  RJB [1], and JRuby [2].  

RJB (RubyJava Bridge) is an extension to the standard Ruby interpreter
that lets you communicate with a Java VM via JNI.  It works pretty
well, but can be a bit 'low level' sometimes, due to the nature of its
implementation.  IE, sometimes you need to know how to construct java
method signatures and such (not a big deal)

JRuby is a complete Ruby interpreter written in Java, so all your Ruby
code runs in the JVM.  This has advantages that the classes can have a
tighter relationship, however the implementation is currently a little
slow, and partially incomplete.  Also, you lose the ability to use
Ruby libraries and extensions written in C.

I've used RJB for a project in order to use the JasperReports library,
and had pretty decent success.  It can be difficult to do proper error
handling, because you have both Ruby errors and Java exceptions to
deal with.  But it is certainly feasible.

It works best when you simply want to call some java code from ruby,
and get the result.  When you start wanting to have ruby classes
inherit from java classes, and have java callback to ruby which calls
back to java, it can get messy.  Just try to keep it as simple as
possible.

Jason

[1]  http://arton.no-ip.info/collabo/backyard/?RubyJavaBridge
[2]  http://jruby.sourceforge.net


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ara.T.Howard  
View profile  
 More options Jun 21 2005, 11:13 am
Newsgroups: comp.lang.ruby
From: "Ara.T.Howard" <Ara.T.How...@noaa.gov>
Date: Wed, 22 Jun 2005 00:13:34 +0900
Local: Tues, Jun 21 2005 11:13 am
Subject: Re: Ruby and Java

On Tue, 21 Jun 2005, Wayne Pierce wrote:
> I have a vendor product with Java APIs that I need to write against
> and would like to use Ruby.

> Does anyone have an opinion on the most reliable way to interact with
> Java from Ruby?  I've seen some different projects, but can't tell if
> there is any major difference between how they are implemented or
> which are actively maintained.

> Thanks,

> Wayne

why not soap objects on bound only to localhost?

-a
--
=========================================================================== ====
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| My religion is very simple.  My religion is kindness.
| --Tenzin Gyatso
=========================================================================== ====


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Probert  
View profile  
 More options Jun 21 2005, 11:23 am
Newsgroups: comp.lang.ruby
From: Mark Probert <probe...@acm.org>
Date: Wed, 22 Jun 2005 00:23:01 +0900
Local: Tues, Jun 21 2005 11:23 am
Subject: Re: Ruby and Java
Hi ..

 On Tuesday 21 June 2005 07:45, Robert Klemme wrote:

> Jean-Claude Arbaut wrote:
> > On 21/06/2005 15:12, Wayne Pierce wrote:
> >> I have a vendor product with Java APIs that I need to write against
> >> and would like to use Ruby.

> I'd use plain old Java.  That'll be much more hassle free and Java isn't
> too bad IMHO.

Some of the other options than using POJ are:

  Scala -- http://scala.epfl.ch/
  Nice  -- http://nice.sourceforge.net/

Both of these are built on the JVM and use the JRE.  With all respect to Ruby,
I have used both when in a Java environment rather than force Ruby into a
place where it is best not to go.

Regards,

--
-mark.  (probertm at acm dot org)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Adam P. Jenkins  
View profile  
 More options Jun 21 2005, 12:16 pm
Newsgroups: comp.lang.ruby
From: "Adam P. Jenkins" <tho...@theshire.com>
Date: Tue, 21 Jun 2005 12:16:15 -0400
Local: Tues, Jun 21 2005 12:16 pm
Subject: Re: Ruby and Java

Wayne Pierce wrote:
> I have a vendor product with Java APIs that I need to write against
> and would like to use Ruby.

> Does anyone have an opinion on the most reliable way to interact with
> Java from Ruby?  I've seen some different projects, but can't tell if
> there is any major difference between how they are implemented or
> which are actively maintained.

Here are some ways to interact with Java from Ruby, though I can't say
which is the most stable:

* JRuby: http://jruby.sourceforge.net/

* RJB: http://arton.no-ip.info/collabo/backyard/?RubyJavaBridge

* RJNI: http://thekode.net/ruby/rjni/index.html

Personally, I'd just use Java, or a more Java-compatible scripting
language like Beanshell (http://beanshell.org) or Groovy
(http://groovy.codehaus.org/).  I like Ruby, but I don't see the point
of jumping through hoops to use it for everything unless you need to
integrate some existing Ruby and Java code.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wayne Pierce  
View profile  
 More options Jun 21 2005, 12:52 pm
Newsgroups: comp.lang.ruby
From: Wayne Pierce <shalo...@gmail.com>
Date: Wed, 22 Jun 2005 01:52:16 +0900
Local: Tues, Jun 21 2005 12:52 pm
Subject: Re: Ruby and Java

> Seems ugly to me, but anyway...

It could get very ugly, but it may be saner in the long run for this
organization.

I had considered using POJ, but want to limit the number of languages
in use here.  So far I have programs in Ruby, Python, shell (/bin/sh)
and sed scripts.  I have also inherited some Perl, Tcl and may soon
receive C# and PHP code (I was able to turn away the VB).

I understand enough about each of the languages to work with the
programs, which is why they come to me when the other person leaves.
However if I ever leave there is nobody here that can pick apart all
of the different languages; I'd rather not add another one to the mix
(Java) if it can be prevented.

For this program I only need to call a function passing in two
parameters from the API.  From what I read concerning some of the
suggestions it should be doable and shouldn't be too difficult.

Thanks for all the responses,

Wayne


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Klemme  
View profile  
 More options Jun 21 2005, 1:36 pm
Newsgroups: comp.lang.ruby
From: "Robert Klemme" <bob.n...@gmx.net>
Date: Tue, 21 Jun 2005 19:36:51 +0200
Local: Tues, Jun 21 2005 1:36 pm
Subject: Re: Ruby and Java

"Mark Probert" <probe...@acm.org> schrieb im Newsbeitrag
news:200506210823.30148.probertm@acm.org...

That's a good suggestion!  Then we should mention groovy also which has some
similarities with Ruby.  However, the last time I looked at it it was still
immature and also terribly slow...

http://groovy.codehaus.org/

Kind regards

    robert


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
SAKURAI Masashi  
View profile  
 More options Jun 21 2005, 6:38 pm
Newsgroups: comp.lang.ruby
From: SAKURAI Masashi <m.saku...@dream.com>
Date: Wed, 22 Jun 2005 07:38:50 +0900
Local: Tues, Jun 21 2005 6:38 pm
Subject: Re: Ruby and Java
Hi,

> I have a vendor product with Java APIs that I need to write against
> and would like to use Ruby.

> Does anyone have an opinion on the most reliable way to interact with
> Java from Ruby?  I've seen some different projects, but can't tell if
> there is any major difference between how they are implemented or
> which are actively maintained.

I have another implementation Java-Ruby bridge that is written in pure
Java and Ruby.

YAJB
http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/cgi-bin/fw/wiki.cgi?pag...

This bridge is implemented by Javassist and xmlrpc communication.
Javassist is bytecode engineering tool. I used xmlrpc to connect java
and ruby.  Although the communication is very slow, the bridge can
establish connection on the many environment.

The YAJB is designed for achievement of following goals:

* easy to use (at least for me, on cygwin/windows XP)
* allowing simple and complete GUI code as we write in Java
* writing implementation of Java interfaces and any class in Ruby.

I wrote the code for my own purpose, analyzing numerical data and
visualizing it with my plot library, not general use.
So I'm sorry if you meet troubles. (I'm not sure using gem or setup.rb...)

Here is the sample YAJB code, handling modal JDialog:

=============================

#!/usr/bin/ruby

require 'yajb/jbridge'
include JavaBridge

jimport "java.awt.*"
jimport "java.awt.event.*"
jimport "javax.swing.*"

label = jnew :JLabel, "Hello World!"

button = jnew :JButton, "open!"
action = jextend :ActionListener
button.addActionListener(action)

panel = jnew :JPanel, jnew(:GridLayout,2,1)
panel.add(label)
panel.add(button)

frame = jnew :JFrame, "JDialog DEMO"
frame.getContentPane.add(panel)
frame.pack

class << action
  def init(f,l)
        @frame = f
        @label = l
  end

  def actionPerformed(event)
        dlg = jnew :JDialog, @frame, "Modal Dialog!", true

        text = jnew :JTextField,12

        okbtn = jnew :JButton,"OK"
        action = jextend :ActionListener
        class << action
          def init(d,t,l)
                @dlg = d; @text = t; @label = l
          end
          def actionPerformed(e)
                @label.setText(@text.getText())
                @dlg.dispose()
          end
        end
        action.init(dlg,text,@label)
        okbtn.addActionListener(action)

        panel = jnew :JPanel
        panel.add(text)
        panel.add(okbtn)

        dlg.getContentPane.add(panel)
        dlg.pack
        dlg.show
  end
end

action.init(frame,label)

wc = jextend :WindowAdapter
class << wc
  def windowClosing(e)
        break_bridge
        wakeup_thread
  end
end
frame.addWindowListener(wc)
frame.show()

stop_thread

=======================


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google