Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby Java Bridge: Are there any?

Reply
Thread Tools

Ruby Java Bridge: Are there any?

 
 
Richard Cole
Guest
Posts: n/a
 
      04-13-2005
Hi. Quick question. I've install a database like thingy (kowari) written
in Java that I want to communicate with from a Ruby: send queries get
answers. What's a good way to communicate from a ruby process to Java
process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
go from ruby straight to the JVM presumably via the java native call
interface? It's all on the same machine, I need only to communicate from
ruby to the Java Client interface that comes with my database thingy
(kowari). The data to be passed back and forth is all strings. The
client interface is a Java Bean. Does that open up any possibilities?

regards,

Richard.


 
Reply With Quote
 
 
 
 
Lyndon Samson
Guest
Posts: n/a
 
      04-13-2005
On 4/13/05, Richard Cole <> wrote:
> Hi. Quick question. I've install a database like thingy (kowari) written
> in Java that I want to communicate with from a Ruby: send queries get
> answers. What's a good way to communicate from a ruby process to Java
> process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
> go from ruby straight to the JVM presumably via the java native call
> interface? It's all on the same machine, I need only to communicate from
> ruby to the Java Client interface that comes with my database thingy
> (kowari). The data to be passed back and forth is all strings. The
> client interface is a Java Bean. Does that open up any possibilities?
>


Sockets would probably be easiest with strings. However if the jruby
and cruby marshall formats are compatable you could use that across
shared memory.


> regards,
>
> Richard.
>
>



--
Into RFID? www.rfidnewsupdate.com Simple, fast, news.



 
Reply With Quote
 
 
 
 
Avik Sengupta
Guest
Posts: n/a
 
      04-13-2005
>A socket? Are there any wrappers that let me
> go from ruby straight to the JVM presumably via the java native call
> interface?


It is possible to compile java bytecodes to native objects via gcj, and
wrap that using Ruby's C interface (either manually, or via SWIG)

 
Reply With Quote
 
David Corbin
Guest
Posts: n/a
 
      04-13-2005
On Wednesday 13 April 2005 12:32 am, Richard Cole wrote:
> Hi. Quick question. I've install a database like thingy (kowari) written
> in Java that I want to communicate with from a Ruby: send queries get
> answers. What's a good way to communicate from a ruby process to Java
> process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
> go from ruby straight to the JVM presumably via the java native call
> interface? It's all on the same machine, I need only to communicate from
> ruby to the Java Client interface that comes with my database thingy
> (kowari). The data to be passed back and forth is all strings. The
> client interface is a Java Bean. Does that open up any possibilities?
>
> regards,
>
> Richard.


Depending on the application, you might consider JRuby. (A ruby implementation
in Java that allows direct calls to Java objects). There are, however,
definately applications for which it is NOT the solution at this point in
it's life.


 
Reply With Quote
 
Takaaki Tateishi
Guest
Posts: n/a
 
      04-13-2005
Richard Cole wrote:
> Hi. Quick question. I've install a database like thingy (kowari) written
> in Java that I want to communicate with from a Ruby: send queries get
> answers. What's a good way to communicate from a ruby process to Java
> process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
> go from ruby straight to the JVM presumably via the java native call
> interface?


Try rjb,
http://arton.no-ip.info/data/rjb-0.1.9.zip
http://arton.no-ip.info/collabo/back...RubyJavaBridge
--
Takaaki Tateishi <>



 
Reply With Quote
 
Luke Galea
Guest
Posts: n/a
 
      04-13-2005
Wow,
RJB looks really nice!

So: Trying to get a handle on use cases for JRuby versus RJB...
JRuby is for embedding ruby in java applications, RJB is for embedding java in
ruby applications? Or is there overlap between the two?

On Wednesday 13 April 2005 12:48, Takaaki Tateishi wrote:
> Richard Cole wrote:
> > Hi. Quick question. I've install a database like thingy (kowari) written
> > in Java that I want to communicate with from a Ruby: send queries get
> > answers. What's a good way to communicate from a ruby process to Java
> > process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
> > go from ruby straight to the JVM presumably via the java native call
> > interface?

>
> Try rjb,
> http://arton.no-ip.info/data/rjb-0.1.9.zip
> http://arton.no-ip.info/collabo/back...RubyJavaBridge



 
Reply With Quote
 
Richard Cole
Guest
Posts: n/a
 
      04-14-2005
Takaaki Tateishi wrote:

> Richard Cole wrote:
>
>> Hi. Quick question. I've install a database like thingy (kowari)
>> written in Java that I want to communicate with from a Ruby: send
>> queries get answers. What's a good way to communicate from a ruby
>> process to Java process, SOAP? RMI? Corba? A socket? Are there any
>> wrappers that let me go from ruby straight to the JVM presumably via
>> the java native call interface?

>
>
> Try rjb,
> http://arton.no-ip.info/data/rjb-0.1.9.zip
> http://arton.no-ip.info/collabo/back...RubyJavaBridge


Wow, cool library. That was just what I was looking for . Can you
think of any reason why I'm getting a SIGHUP? Here's my short ruby
program, maybe there's something obvious.

----
require 'rjb'
include Rjb

def file_contents_of(filename)
result = nil
File.open(filename) { |file| return file.read() }
return result
end

queryString = file_contents_of('example.itql')
load("itql-1.1.0.jar")
iTQLInterpreterBeanClass = import('org.kowari.itql.ItqlInterpreterBean')
iTQL = iTQLInterpreterBeanClass.new
answer = iTQL.executeQuery(queryString)

vars = answer.getVariables
while answer.next do
for i in 1..vars.length do
puts "i=#{i} val=#{answer.getObject(i-1).toString()}"
end
end
----

Output is:

[snip]
i=1 val=grrg.apache.bcel.classfile.Signature%24MyByt eArrayInputStream
i=1 val=gr:java.io.ByteArrayInputStream
itql.rb:19: SIGHUP (SignalException)

Each time I run the program the SIGHUP comes either on answer.next or
answer.getObjects... and with a different amount of output.

regards,

Richard.



 
Reply With Quote
 
vruz
Guest
Posts: n/a
 
      04-14-2005
> Hi. Quick question. I've install a database like thingy (kowari) written
> in Java that I want to communicate with from a Ruby: send queries get
> answers. What's a good way to communicate from a ruby process to Java
> process, SOAP? RMI? Corba? A socket? Are there any wrappers that let me
> go from ruby straight to the JVM presumably via the java native call
> interface? It's all on the same machine, I need only to communicate from
> ruby to the Java Client interface that comes with my database thingy
> (kowari). The data to be passed back and forth is all strings. The
> client interface is a Java Bean. Does that open up any possibilities?


SOAP4R comes standard with Ruby 1.8.x
(for a brief introduction have a look at: http://www.simplesiteuk.com)

I haven't heard of any RMI lib freely available in native Ruby

There's also RJNI: Java binding for Ruby through JNI
http://thekode.net/ruby/rjni/index.html
(though unsupported at the moment, would be interesting for someone to
pick it up)

You may consider JRuby can be a good option for some projects:
http://jruby.sourceforge.net/

There are some other JNI bindings available, can't recall the names
now, someone will probably help adding to the list in this thread.

cheers,
vruz



 
Reply With Quote
 
Richard Cole
Guest
Posts: n/a
 
      04-14-2005
Richard Cole wrote:

> Takaaki Tateishi wrote:
>
>> Richard Cole wrote:
>>
>>> Hi. Quick question. I've install a database like thingy (kowari)
>>> written in Java that I want to communicate with from a Ruby: send
>>> queries get answers. What's a good way to communicate from a ruby
>>> process to Java process, SOAP? RMI? Corba? A socket? Are there any
>>> wrappers that let me go from ruby straight to the JVM presumably via
>>> the java native call interface?

>>
>>
>>
>> Try rjb,
>> http://arton.no-ip.info/data/rjb-0.1.9.zip
>> http://arton.no-ip.info/collabo/back...RubyJavaBridge

>
>
> Wow, cool library. That was just what I was looking for . Can you
> think of any reason why I'm getting a SIGHUP? Here's my short ruby
> program, maybe there's something obvious.


Don't know where SIGHUP is coming from, but putting a signal handler in
at the top of the ruby script allowed me to ignore SIGHUP, i.e:

trap('SIGHUP') {
# puts "SIGHUP Raised!"
}

and now the program is producing the correct output, i.e. correctly
iterating through the result set.

regards,

Richard.



 
Reply With Quote
 
David Corbin
Guest
Posts: n/a
 
      04-16-2005
On Wednesday 13 April 2005 09:30 am, Luke Galea wrote:
> Wow,
> RJB looks really nice!
>
> So: Trying to get a handle on use cases for JRuby versus RJB...
> JRuby is for embedding ruby in java applications, RJB is for embedding java
> in ruby applications? Or is there overlap between the two?
>


I"m not familiar with RJB, but JRuby can work "both ways". In fact, I use it
exclusively for times when I need to call Java code from a Ruby application.

David


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a ruby visualizer somewhere? Python one below is veryhelpful but can't find anything that ruby has Eden Chen Ruby 1 12-09-2012 09:54 AM
Ruby to java or java to ruby converter Vinod Kone Ruby 7 01-22-2007 02:17 AM
Is there C/C++ corresponding function in Linux for Java's java.util.Locale.getCountry? xiebopublic@gmail.com C++ 2 07-23-2006 04:27 PM
Is there a java.util.Scanner that works in 1.4.2 out there? Danno Java 2 04-26-2006 04:41 AM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57