Thursday May 17, 2007
Getting Started with JRuby - Tutorial at RailsConf rails
![]() |
Earlier today, I attended Charles Nutter and Thomas Enebo "Your First Day with JRuby on Rails" tutorial at Rails Conf 2007. The key message is Ruby as the programming language and Java for the platform and libraries provides the best of both worlds to developers. |
|
|
|
|
JRuby is 100% pure-Java implementation of the
Ruby programming language. The goal is to use the power of Ruby programming
language and leverage the power of Java platform. Read a more detailed tutorial
here. All Ruby scripts work with JRuby instead of the original C-based
implementation. Also the goal is NOT an attempt to alter Ruby or add
incompatible features. You can download
JRuby implementation, unzip it and
set JRUBY_HOME to the installation directory. Here is a sample JRuby code:
1. require 'java'
2. include_class 'java.lang.ArrayList'
3. include_class 'javax.swing.JFrame'
4.
5. list = ArrayList.new
6. frame = JFrame.new("Ruby SWINGS!")
7. list << frame
8. list.each { |f| f.set_size(200, 200) }
9. puts frame.title
The code above shows how Ruby and Java code can be mixed with each other.
Line 1 includes Java support. Line 2 imports Java classes. Line 5 and 6 creates
a new variables using a mix of Java and Ruby syntax. Line 7 and 8 uses the
instance variables in Ruby syntax. Line 9 prints the title of the frame. If you
run this code using JRuby interpreter then you get:
%JRUBY_HOME%/bin/jruby sample1.rb
Ruby SWINGS!
Here are some of the differences (from the original C-based implementation) in JRuby:
database.yml' fromdevelopment:
adapter: mysql
database: HelloWorld_development
username: root
password:
host: localhost
to
development:
adapter: jdbc
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/helloworld_development
username: root
password:require 'jdbc_adapter'" in 'environment.rb'.work/jruby/lib'
directory.Here are some other points that the tutorial talked/showed:
gem install glassfish-rails
jruby script/server glassfish
=> Starting GlassFish
=> Rails application on http://localhost:8080/8080
=> Rails application on http://localhost:8080/4848
=> Clustering enabled
=> Connecting pooling enabled
=> Load balancing enabled
=> Server Ready.The biggest pain point from the audience was Rails deployment. With JRuby and GlassFish, you can continue deploying your apps on Mongrel. Because of JRuby, it also allows you to deploy your RoR applications on GlassFish, open-source, production-quality, Java EE 5 compatible application server.
BTW, there is supposed to be wireless connectivity through out the conference but it's very spotty :(
Technorati: glassfish rubyonrails ror netbeans railsconf
Posted by Arun Gupta in web2.0 | Comments[4]
|
|
|
|
|
Today's Page Hits: 167
Total # blog entries: 994
| « November 2009 | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
1 | 2 | 4 | 6 | 7 | ||
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | |||||
| Today | ||||||
Posted by Inchoate Curmudgeon on May 17, 2007 at 01:17 PM PDT #
Posted by jruby fan on May 18, 2007 at 12:56 PM PDT #
Posted by Arun on May 29, 2007 at 09:25 AM PDT #
dsf
Posted by 124.30.174.15 on October 23, 2008 at 02:29 AM PDT #