gamelan
Search EarthWeb
CodeGuru | Gamelan | Jars | Wireless | Discussions
Navigate developer.com
Architecture & Design  
Database  
Java
Languages & Tools
Microsoft & .NET
Open Source  
Project Management  
Security  
Techniques  
Voice  
Web Services  
Wireless/Mobile
XML  
New
 
Technology Jobs  

   Developer.com Webcasts:
  The Impact of Coding Standards and Code Reviews

  Project Management for the Developer

  Defining Your Own Software Development Methodology

  more Webcasts...




Vote for the Developer.com Product of the Year Winners!




Developer Jobs

Be a Commerce Partner














 


Related Article -
RJS Templates: Adding Some Ajax Goodness to Rails
Change your View: Enhancing the User Interface of a Ruby on Rails Application
Skip the CRUD: Building a Simple Database Backed Web Application Using Ruby on Rails
Ruby on Rails: All Aboard the Fast Train to Web Application Development
JRuby: Java and Ruby Together at Last
Ruby for the REST of Us: Using Ruby and REST to Integrate with Amazon S3
Developer News -
The Key to Rapid App Dev? Process.    December 1, 2008
PartyGaming Bets on Open Source    December 1, 2008
Google's Underdog Eyes iPhone's Lead in Apps    November 28, 2008
A Networking Idea That's Out of This World    November 26, 2008
Free Tech Newsletter -

Running Your First Rails Application on JRuby
By Dominic Da Silva

Go to page: 1  2  Next  

JRuby (the 100% pure Java implementation of the Ruby programming language) has been gaining more and more attention in the Java and Ruby communities. In my first JRuby article, "JRuby: Java and Ruby Together at Last," I showed some basic usage of JRuby, and closed the article with a small Swing sample written in JRuby. At that time, the current version of JRuby was 0.9.1. Since then, version 0.9.2 has been released with improved support for Rails. With this current release, the ability to run a simple Rails application has been added. In this article, you will upgrade to JRuby 0.9.2, create a simple Rails application, and run it on JRuby.

The Current State of Ruby on Rails Support in JRuby

With three official releases under its belt (0.9.0, 0.9.1 and 0.9.2), JRuby is almost at the milestone of fully supporting Ruby on Rails. This means that Ruby on Rails applications will be able to run on JRuby without modification. JRuby developers have been working hard to get JRuby to pass all tests of the Ruby on Rails test suite and as Charles Nutter (lead JRuby developer) notes in his latest Rails support status update, they are very close. With that in mind, you can get a Rails application up and running on JRuby to see what it entails. First, you need to upgrade to the latest JRuby version.

Upgrading to JRuby 0.9.2

The JRuby distribution comes as a tar.gz file. For this article, I will be working on a Windows-based system running Java SE version 1.5.0_10. The latest JRuby version is available at http://dist.codehaus.org/jruby/. The file to download is jruby-java5-bin-0.9.2.tar.gz. Uncompress the archive; you should end up with a jruby-0.9.2 folder which contained subfolders: bin, docs, lib and samples. You can add a JRUBY_HOME environment variable pointing to this directory and then add the %JRUBY_HOME%bin ($JRUBY_HOMEbin on UNIX) to your system PATH. The JRuby distribution's bin directory contains the jruby.bat file that is used to run the JRuby interpreter. Run the command jruby .version from the command line to test that the JRuby is working:



Click here for a larger image.

Installing Rails into JRuby

Now that you have JRuby 0.9.2 installed, you can install Rails into your JRuby installation. You will use JRuby's 'gem' command to download and install Rails:



Click here for a larger image.

The '.y .-no-ri .-no-rdoc' command line switches tell gem to install all dependencies, but skip the installation of Rails documentation (because this takes a very long time). As can be seen from the console, you installed rails, rake, activesupport, activerecord, actionpack, actionmailer, and actionwebservice.

So, you now have Rails installed in JRuby. You can verify this by looking into the JRuby installation directory:



Click here for a larger image.

As you can see, the version of Rails that was installed into JRuby is version 1.2.2.

Creating Your First JRuby on Rails Application

You now can create your first JRuby on Rails application. Because you are running JRuby on Rails on Windows, you need to perform one extra step to allow you to use the Windows 'rails' and 'rake' commands. I assume you have an installation on Ruby and Ruby on Rails on your hard drive. You will need to copy the 'rails.cmd' and 'rake.cmd' files from the 'bin' directory of your Ruby installation over to the 'bin' directory of your JRuby 0.9.2 installation:



Click here for a larger image.



Click here for a larger image.

You will need to Issue to command '%JRUBY_HOME%/bin/rails myfirstjrorapp' to create a JRuby on Rails application called 'myfirstjrorapp'.



Click here for a larger image.

Go to page: 1  2  Next  


Tools:
Add www.developer.com to your favorites
Add www.developer.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed


Enterprise Java Archives






internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers