Archive for the ‘Java & JRuby’ Category

JRuby 1.1.5 Released

Nov 3rd, 2008 by Robert Dempsey - Tags:

Leave a Comment

Thomas Enebo just announced the lastest point release of JRuby – 1.1.5. Here’s a snippet:

“JRuby 1.1.5 is the fifth point release of JRuby 1.1. The fixes in this release are primarily obvious compatibility problems and performance enhancements. Our goal is to put out point releases more frequently for the next several months (about 3-4 weeks a release). We want a more rapid release cycle to better address issues brought up by users of JRuby.”

Highlights:

  • Per-class method caching (improves _send_, respond_to?, and defined?)
  • Constant cache dramatically improves constant lookup
  • Reduced memory usage for compiled execution
  • Several Java Integration regressions fixed
  • Rubygems 1.3.1 and Rspec 1.1.11 upgrades
  • Updated ffi (Foreign Function Interface) support
  • More Ruby 1.9 mode support
  • 113 bugs fixed since 1.1.4

To see all the goods read the official release post.

The JRuby team just released version 1.1.4, which resolved 72 issues since the 1.1.3 release. 1.1.4 deals with compatibility issues, enhances performance (2-20x speed up of most features – calls, construction, arrays), and takes steps toward Ruby 1.9 compatibility (enabled with –1.9 flag). Read the full details about the release and then download JRuby 1.1.4. Happy coding!

JRuby 1.1.3 Released

Jul 19th, 2008 by Robert Dempsey - Tags:

Leave a Comment

JRuby 1.1.3 was released today. This release includes “primarily obvious compatibility problems and performance enhancements.” The highlights of this release, per the official post by Thomas Enebo, are:

  • RubyGems 1.2
  • Greatly improved interpreter performance
  • jrubyc compiler usability improvements and bug fixes
  • Reduced memory usage and object churn
  • Dozens of IO-related and core class RubySpec fixes + reduced memory for IO
  • ThreadGroup fixes to resolve Mongrel “dead thread” issues
  • New options/properties for tweaking JIT, thread pooling, and more
  • Block invocation performance improvements
  • Much faster Time performance
  • Much better support for –debug
  • Mentioning that context classloader fix would be nice (since it quite user visible, and many users seen/asked for it). JRUBY-2495
  • 82 issues resolved since JRuby 1.1.2

Download the 1.1.3 release.

We work with a number of enterprise-level clients who have a lot of existing Java infrastructure in place. Usually the IT department is running the show and determines what is installed on servers. Sometimes they demand that that be Java.

For the past few weeks I have been reviewing the latest Java web frameworks to see what we should add to our toolbox. What I’m looking for is a web framework that gives us the productivity benefits of Rails, and doesn’t require me to write as much Java code as years past. I was lucky enough to meet Keith Donald, the lead of the Web Product team at SpringSource, at the Orlando Java Users Group. Kevin discussed Spring 2.5, which looks very cool, so I’m looking into it. Previously though, our lead developer Chris had told me about Groovy and Grails, which looks very similar to Rails (MVC, use of an ORM). As Groovy and Grails appeared to have the least amount of learning curve, and I could buy a relatively up-to-date book on it, I started there.

I’m running the soylatte version of Java on my Mac. Unfortunately, the latest versions of Groovy and Grails didn’t seem to like it. So, as I am a fan of using the latest stuff, I fired up VMWare Fusion and installed Ubuntu 8.04 desktop edition. Once Ubuntu was installed and updated, here is how I got everything going.

Installing Java

To install the latest version of the JDK (1.6.0_06-b2), run the following command in your terminal:

sudo apt-get install sun-java6-jdk

Java should be added to your $PATH variable. Test it out by running:

java -version

If it prints out the version number you are good to go.

Installing Groovy

I installed the latest stable version of Groovy – 1.5 at the time of this writing – using apt-get as well.

sudo apt-get install groovy

Installing Grails

To install Grails browse over to the Grails homepage and download the latest version (1.0.3 for me). I recommend getting the tar/gz version. Once you have it local, unpack it and put it where you want it (i.e. /home/rdempsey/grails-1.0.3). I use my home path on a development machine; don’t do that in production. Once you have the files in place, add the Grails bin directory to your $PATH to ensure that you can execute Grails from the command line.

/home/rdempsey/grails-1.0.3/bin

Installing NetBeans

The latest release of NetBeans, 6.5 Milestone 1, supports Groovy and Grails natively. Browse to the NetBeans homepage and download the “Web and Java EE version,” unless of course you want all the goods. You’ll need the web version at a minimum. Once the file is downloaded, make sure it’s executable:

chmod +x netbeans-6.5_m1-javaee-linux.sh

Launch the installer and follow the instructions.

./netbeans-6.5_m1-javaee-linux.sh

Once NetBeans is installed, fire it up go to Tools -> Options. Click the Groovy icon. You should see two tabs: Grails, and Groovy. Click the Grails tab, and enter in the path to Grails. Next, click the Groovy tab. If the Groovy path isn’t already filled in (with /usr/share/groovy), put in the path to the Groovy root directory.

Ready to Roll

You should now be ready to develop your first Groovy and Grails application.

The first half of 2008 has seen a great number of happenings in the Ruby and Rails worlds. Here are the top ten for the first half of 2008.

  • June 23, 2008 – Rails scales – LinkedIn serves 1 billion pages using Rails
  • June 1, 2008 – Rails 2.1 is released
  • May 31, 2008 – Ruby 1.8.7 is released
  • May 30, 2008 – Joel Spolsky keynotes RailsConf 2008
  • May 30, 2008 – FiveRuns released TuneUp to help with Rails performance optimization
  • May 27, 2008 – JRuby 1.1.2 is released, and runs Rails 2.1 like a champ
  • April 13, 2008 – Phusion Passenger (mod_rails) is released
  • April 11, 2008 – Rails core moves to Github, prompting many to move with them
  • April 2, 2008 – Morph Labs makes Rails deployments to EC2 a cinch
  • January 1, 2008 – Thin comes on the scene as an alternative to Mongrel

See something I missed? Drop us a comment below.

Installing the JDK 1.6 on Mac OS X

Feb 26th, 2008 by Robert Dempsey - Tags: ,

Leave a Comment (79)

UPDATE 6/16/09: I ran Software Update on my Mac last night and it appears that Apple has released an update to Java. I’m now rocking 1.6 natively. Update today.

UPDATE: due to folks running into trouble with this post I’ve created a much more detailed video for installing the JDK 1.6 on the Mac.

In my last post, Create and Deploy a JRuby app to the GlassFish gem in 10 minutes or less on Mac OS X, I mentioned using the JDK 1.6 (a.k.a. SoyLatte) to get the performance benefits from JRuby 1.1 RC2. Installing it is a snap, no compiling necessary. Here is what to do:

  • Download SoyLatte 1.0.2 for Mac OS X 10.4 and 10.5. For authentication use username: jrl, password: I am a Licensee in good standing
  • Unzip the package and put the entire directory where you want it
  • Optional: rename the folder to soylatte16-1.0.2
  • Add the soylatte16-1.0.2/bin path to your $PATH variable to use soylatte rather than the JDK 1.5 that comes installed
  • Fire up a terminal session and type “java -version

If everything worked out, you should see something similar to:

java version "1.6.0_03-p3"
Java(TM) SE Runtime Environment (build 1.6.0_03-p3-landonf_03_feb_2008_02_12-b00)
Java HotSpot(TM) Server VM (build 1.6.0_03-p3-landonf_03_feb_2008_02_12-b00, mixed mode)

Enjoy the performance!

Keep up with everything going on with Atlantic Dominion Solutions by subscribing to our monthly newsletter.

The JRuby and Glassfish teams have made installing, building, and launching a JRuby on Rails app a rather trivial process. Glassfish, a Java app server, has been reduced in size from a 22.5 MB install to 2.5 MB Ruby gem (not too shabby for a full app server). If you need the full monty (not covered here) or you need to deploy to another Java app server, install the warbler gem. The combination of Rails 2.0.2 (stable), JRuby 1.1 RC2, the Glassfish gem, and JDK 1.6 is not only breaking down enterprise barriers but speeding up apps all over the place.

So how do we get started with all this, in 10 minutes or less? Let’s take a look.

Overview
Here are the steps we will take to build our first JRuby on Rails application:

  • Download and install JRuby
  • Install Rails and the dependent gems
  • Install the Open-SSL gem
  • Install the GlassFish gem
  • Create a test JRuby on Rails app
  • Deploy our little app to the GlassFish gem

“Make it so Number 1″

First, download JRuby 1.1 RC2. Unpack it into a directory and edit your bash_profile to include the bin directory in your $PATH so you can easily call JRuby executables. Mine looks like this: /Users/rdempsey/Documents/jruby/jruby-1.1RC2/bin. Open up a terminal session and type jruby –version to see if you are successful. If you are, you should see something like this:

$ jruby --version
ruby 1.8.6 (2008-02-16 rev 5944) [i386-jruby1.1RC2]

Now that JRuby is installed (and yes, ready to go), let’s install Rails:

$ jruby -S gem install rails --no-ri --no-rdoc
Successfully installed activesupport-2.0.2
Successfully installed activerecord-2.0.2
Successfully installed actionpack-2.0.2
Successfully installed actionmailer-2.0.2
Successfully installed activeresource-2.0.2
Successfully installed rails-2.0.2
6 gems installed

For full SSL support (and why not have it) install the jruby-openssl gem too.

$ jruby -S gem install jruby-openssl --no-ri --no-rdoc
Successfully installed jruby-openssl-0.1.1
1 gem installed

Now for the Glassfish gem. One command should get us going.

$ jruby -S gem install glassfish
Successfully installed glassfish-0.1.1-universal-java
1 gem installed

Great. How are we on time? 8 minutes to go? Perfect. Let’s create our test Rails app.

$ jruby -S rails --database mysql testapp
... Rails code being generated ...

Change into the directory of testapp and fire up your favorite editor. I like TextMate, though the new NetBeans is looking HOT. Once inside, open up config/database.yml and change the username/password for your MySQL server as necessary. In your terminal and in the root of your app, run the following rake command to create the development database:

$ rake db:create

It may not seem like anything happened, but if you fire up your MySQL gui tool of choice (or go command line) you will see that the testapp_development database has been created. Now to create a migration and test things out. Let’s make a widget.

$ script/generate scaffold Widget name:string description:text
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/widgets
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      create  app/views/widgets/index.html.erb
      create  app/views/widgets/show.html.erb
      create  app/views/widgets/new.html.erb
      create  app/views/widgets/edit.html.erb
      create  app/views/layouts/widgets.html.erb
      create  public/stylesheets/scaffold.css
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/widget.rb
      create    test/unit/widget_test.rb
      create    test/fixtures/widgets.yml
      create    db/migrate
      create    db/migrate/001_create_widgets.rb
      create  app/controllers/widgets_controller.rb
      create  test/functional/widgets_controller_test.rb
      create  app/helpers/widgets_helper.rb
       route  map.resources :widgets

With Rails 2.0.2 we don’t have to specify the timestamp fields, those are automatically added to the migration. Now, run “rake db:migrate” to add your database table.

$ rake db:migrate
(in /Users/rdempsey/Documents/jruby/testapp)
== 1 CreateWidgets: migrating =================================================
-- create_table(:widgets)
   -> 0.4622s
== 1 CreateWidgets: migrated (0.4624s) ========================================

And now for the fun part, deploying the app to the GlassFish gem. Change to the parent directory of your application (getting out of the root directory) and run the following command:

$ jruby -S glassfish_rails testapp
Feb 18, 2008 5:03:00 PM com.sun.enterprise.v3.server.AppServerStartup run
... GlassFish firing up...
INFO: Loading application testapp at /
Starting Rails instances
... Rails instantiation info...
INFO: Glassfish v3 started in 24766 ms

As with Mongrel, the GlassFish gem starts our server on port 3000. Fire up your browser and go to http://localhost:3000/widgets and play around.

JRuby on Rails app

Pretty nice eh? Looks like we have time to spare as well. Go make yourself that next pot of coffee and see what else you can do with this new found power. Let us know how things turn out as well.

Connect with me on LinkedIn, Twitter, or recommend me on Working With Rails.

JRuby 1.1 RC2 Released

Feb 17th, 2008 by Robert Dempsey - Tags: ,

Leave a Comment (2)

Thomas Enebo announced the release of JRuby 1.1 RC2 this past Saturday. The focus of the release is improved speed and refinement. He also says that RC2 uses less memory, and can compile in either Ahead of Time (AIT) or Just In Time JIT) mode. Charles Nutter then followed up with a post of his own letting us know what is next on the agenda for the JRuby team.

They are asking for you to download RC2 and provide feedback.

If you’ve used JRuby, let us know about your experience.

Connect with me on LinkedIn, Twitter, or recommend me on Working With Rails.

JRuby 1.0.2 Released

Nov 2nd, 2007 by Robert Dempsey - Tags:

Leave a Comment

The JRuby team announced that they have released version 1.0.2 which includes fixes for Windows users, support for Rails 1.2.5, 99 total resolved issues since 1.0.1, and more. These guys are busy! Grab the latest on the JRuby site and get integrating.

Robert Dempsey, Project Director of ADS and Founder of Rails For All, will be speaking at the Sarasota Java Users Group meeting on November 15th. The talk with be a front to back overview of Ruby on Rails. Here’s what you get:

Ruby

  • Overview
  • Ruby’s growth
  • Objects everywhere
  • Ruby is flexible

Ruby on Rails

  • Overview
  • Why Ruby on Rails
  • Uses of Ruby on Rails

How to create a basic Rails application

  • Create a Rails application
  • What is MVC
  • The structure of a Rails application (where everything is)
  • Connect to a database
  • Create scaffold
  • Fire it up and see what we have

Testing the Rails (if there is time)

  • BDD (our preferred approach)
  • RSpec

Come and enjoy! We will see you there.

Collaborate.
Enable.
Succeed.

Contact

(888) 331-8520
4210 Beau James Court
Winter Park, Florida 32792 RSS Feed

Search

Popular Articles

Recent Articles