Running Your First Rails Application on JRuby
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:
If you get an error such as the following:
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:
That is it. You have created your first JRuby on Rails application!
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.
- 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.
Page 2 of 2