From: "Mauricio Fernández" Date: 2003-08-14T02:50:38+09:00 Subject: Re: Java/Ruby communication On Thu, Aug 14, 2003 at 02:23:50AM +0900, Hal E. Fulton wrote: > ----- Original Message ----- > From: "Brian McCallister" > To: "ruby-talk ML" > Sent: Wednesday, August 13, 2003 12:07 PM > Subject: Re: Java/Ruby communication > > > > ruby opens TCPServer > > Java opens TCPSocket > > > > Java says "hello\r\n" > > ruby says "hiya\r\n" > > > > Voila, communication. Anything else is just protocol ;-) > > Fine... now let's see you write a Ruby program > that instantiates a Java object and invokes a > method on it... batsman@tux-chan:~/src/rjni$ irb --simple-prompt /home/batsman/usr/lib/ruby/1.8/irb/context.rb:180: warning: method redefined; discarding old use_readline= >> require 'rjni/reflect' => true >> include RJNI => Object >> jvm = JVM.new # init jvm => # >> JString = Reflect["java.lang.String"] => #, @getConstructorsID=getConstructors, @handle=java.lang.String> >> o = JString.new "String Passed From Ruby"; nil => nil >> o.startsWith("String").to_b => true >> o.startsWith("Sds").to_b => false startsWith is public boolean java.lang.String.startsWith(java.lang.String). -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Linux: Where Don't We Want To Go Today? -- Submitted by Pancrazio De Mauro, paraphrasing some well-known sales talk