Running Your First Rails Application on JRuby Los Angeles CA

Work step-by-step to install Rails into your JRuby installation and get a simple Rails application up and running.

Local Companies

Moyea Software
92295612365
Hot building, ring street
LA, CA
Interneer Inc.
8005586832 x85
6101 W. Centinela Ave.
Culver City, CA
Cornerstone Concepts Inc
818-247-3909
600 W Broadway
Glendale, CA
Greene Computer Corporation
(818) 956-4961
200 S. Louise Street
Glendale, CA
Corticalx Inc Software Solutions & Technology
818-500-0881
425 E Colorado St
Glendale, CA
Alphatier Systems
818-409-8920
517 Griswold St
Glendale, CA
TimeTECH - Customizable Time and Attendance / Workforce Management Solutions
905-677-7009
7420 Airport Rd 203
Mississauga, CA
Hutchinson & Bloodgood, LLP
(818) 637-5000
101 N. Brand Blvd. #1600
Glendale, CA
Telsoft Solutions
818-545-8680
100 N Brand Blvd
Glendale, CA
Abraxas Technologies Inc
818-502-9100
450 N Brand Blvd
Glendale, CA

provided by: 
Originally published at Internet.com


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.

Change to the 'myfirstjrorapp' directory and run the command 'jruby scriptserver'. This will start the Rails built-in 'WEBrick' web server and start your application on port 3000:



Click here for a larger image.

If you get an error such as the following:



Click here for a larger image.

It means that your Ruby on Rails installation is older than the JRuby on Rails installation and therefore the 'myfirstjrorapp' is looking for the older Ruby on Rails version. In your case, the Ruby on Rails version is 1.2.1, but the JRuby on Rails version is 1.2.2. To fix this, edit the 'myfirstjrorappconfigenvironment.rb' file and update the RAILS_GEM_VERSION variable: # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '1.2.2' unless defined? RAILS_GEM_VERSION

Now, you can point your browser to http://localhost:3000/. you should see the following:



Click here for a larger image.

That is it. You have created your first JRuby on Rails application!

Conclusion

This article has provided you with a step-by-step process to install Rails into your JRuby installation and get a simple Rails application up and running. Take some time to look further into JRuby and Ruby on Rails and see what it has to offer you.

References

* Ruby: http://www.ruby-lang.org/en/ * Java: http://java.sun.com/ * Java Programming Language: http://en.wikipedia.org/wiki/Java_language * JRuby: http://jruby.codehaus.org/ * Bringing Ruby to the JVM: http://www.infoq.com/presentations/JRuby * JRuby Wiki: http://www.headius.com/jrubywiki/index.php/Main_Page * Sun hires JRuby developers: http://www.tbray.org/ongoing/When/200x/2006/09/07/JRuby-guys * Ruby on Rails: http://www.rubyonrails.org/ * SilvaSoft, Inc. weblog: http://jroller.com/page/silvasoftinc

About the Author

Dominic Da Silva (http://www.dominicdasilva.com/) is the President of SilvaSoft, Inc., a software consulting company specializing in Java, Ruby, and .NET-based web and web services development. He has worked with Java since the year 2000 and is a Linux user from the 1.0 days. He is also Sun Certified for the Java 2 platform. Born on the beautiful Caribbean island of Trinidad and Tobago, he now makes his home in sunny Orlando, Florida.

Author: Dominic Da Silva

Read article at Internet.com site

Featured Local Company

Moyea Software

92295612365
Hot building, ring street
LA, CA

Related Local Events
Automation Technology Expo West (ATX West)
Dates: 2/9/2010 - 2/11/2010
Location: Anaheim Convention Center
Anaheim, CA
View Details

SOLAR POWER - Exhibition and Conference
Dates: 10/12/2010 - 10/14/2010
Location: Los Angeles Convention & Exhibition Center
Los Angeles, CA
View Details

REAL-TIME & EMBEDDED COMPUTING CONFERENCE - LONG BEACH 2009
Dates: 10/1/2009 - 10/1/2009
Location: Marriott Long Beach
Long Beach, CA
View Details

2009 IEEE Petroleum and Chemical Industry Technical Conference (PCIC 2009)
Dates: 9/14/2009 - 9/16/2009
Location:
Anaheim, CA
View Details

Medical Design & Manufacturing - Trade
Dates: 6/9/2009 - 6/11/2009
Location: CANON COMMUNICATIONS LLC
Los Angeles, CA
View Details