The Artima Developer Community
Sponsored Link

Agile Buzz Forum
You Got Your Java In My Ruby Code!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jared Richardson

Posts: 1031
Nickname: jaredr
Registered: Jun, 2005

Jared Richardson is an author, speaker, and consultant who enjoys working with Ruby and Rails.
You Got Your Java In My Ruby Code! Posted: Sep 1, 2006 5:50 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Jared Richardson.
Original Post: You Got Your Java In My Ruby Code!
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog. The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Jared Richardson
Latest Posts From Jared's Weblog

Advertisement

I'm working on a project that requires both Ruby and Java and I was surprised at several rather mature projects that make this easy.

First I looked at the best known project in this space, . JRuby is an amazing project. They are running Ruby code from with Java code. And it works very nicely. If you're working on a Java project but you could make more time if you had access to some Ruby bits, check this one out.

However, for my project, JRuby wasn't appropriate. I'm trying to write another Rails database adapter (this time for the Hypersonic database) and the database is written in Java. Using JRuby would've meant keeping up a Java faux-server to listen for connections from my Ruby client. That didn't seem ideal to me.

I found two other projects that looke promising though. First, the Ruby Java Bridge (RJB). Unfortunately, the "out of the box" experience wasn't so good for me... it didn't work on my Mac laptop.

When I was hitting the search engines to see if anyone else had run into my issues, I found Yet Another Java Bridge. YAJB just worked. :) You can't beat a one line install... ruby setup.rb.

Using the bridge is trivial. Here's the obligatory Hello World code:

require 'yajb/jbridge'
include JavaBridge
jimport "javax.swing.*"

:JOptionPane.jclass.showMessageDialog( nil, "Hello World!")
That's Ruby code that pops up a Java dialog... not bad! I'm not going to code it up to prove it, but this looks like less code than you could use to do the same in a Java only program.

I can see projects like YAJB becoming a very popular way to wrap your legacy Java code so that projects like Ruby on Rails can access it.

Enjoy!

Jared

Read: You Got Your Java In My Ruby Code!

Topic: Objective-C 2.0 Previous Topic   Next Topic Topic: .NET Rocks!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use