Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Reuse Java code in your Ruby on Rails applications

Cross the Ruby-Java divide with the Ruby Java Bridge

Santhosh Krishnamoorthy, Staff Software Engineer, IBM Software Labs, Bangalore
Santhosh Krishnamoorthy is a test engineer with TXSeries in IBM Software Labs, Bangalore, working in the area of intersystem communications. Recently, he has been getting his hands wet with Ruby, Ruby on Rails, and Python programming.
(An IBM developerWorks Contributing Author)

Summary:  The Ruby Java Bridge (RJB) lets you load Java™ classes directly to, and call them from, Ruby on Rails applications. This tutorial shows how you can put this toolkit to work by reusing your legacy Java Web application code in a modern Web development platform.

Date:  05 Jun 2008
Level:  Intermediate PDF:  A4 and Letter (44 KB | 13 pages)Get Adobe® Reader®

Activity:  9646 views
Comments:  

Before you start

About this tutorial

Ruby on Rails (Rails) is a full-stack Web application framework written in Ruby — a feature-rich, free, simple, extensible, portable, object-oriented scripting language. Rails has gained immense popularity among Web application developers. With it, you can quickly and efficiently develop a Web application and deploy it into any Web container, such as IBM® WebSphere® or Apache Tomcat.

Before Rails and similar Web application development frameworks were available, the de facto standard tool for the job was the Java language, thanks to its platform independence and comprehensive API set. Many Java Web applications are still running, resulting in the ready availability of much useful, well-written Java code (loosely referred to in this tutorial as legacy code). Legacy Java code is usually packaged as a set of JAR files.

If you change your Web application development platform to Rails, you can reuse legacy Java code. The Ruby Java Bridge (RJB) is a toolkit that lets you load JAR files into your Rails application and access the methods and variables in them. This tutorial explains how to configure and use RJB in a Rails application.


Objectives

In this tutorial, you will learn how to:

  • Download, compile, and install RJB
  • Set up RJB to access shared Java libraries
  • Load and access legacy Java code in a Rails application

The tutorial does not delve deeply into the capabilities of Rails. One of Rails' many strong points, compared to other Web frameworks, is the quality and quantity of documentation available for the platform (see Resources).


Prerequisites

This tutorial assumes basic familiarity with the Java language, Ruby, and Ruby on Rails.


System requirements

This tutorial assumes that you are working on a Linux® system. (However, the steps are essentially the same for Windows®.) It also assumes that you have a working setup of Ruby on Rails. If not, see Resources for links to documentation that can help you install and configure Rails for your system.

RJB requires that you have a Java SDK installed on your system. If you need to, download the latest Java SE SDK for your platform and install it now.

1 of 7 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology, Web development, Open source
ArticleID=311771
TutorialTitle=Reuse Java code in your Ruby on Rails applications
publish-date=06052008
author1-email=santhoshk@in.ibm.com
author1-email-cc=jaloi@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).