Begin main content

Camping with JRuby and NetBeans 6.0

Camp Beans!NetBeans 6.0 is shaping up as a very good Ruby development environment, and JRuby is quickly becoming a viable platform.

If you're looking for a different kind of beans with a different kind of camping, you might want to check out Big Jim's Camping Beans :)

I love what Thoughtworks Studios have done in Mingle, making it so easy to deploy by using an embedded java database (derby), JRuby and Ruby on Rails.

I also love the concepts why has used in Camping and I figured the three combined would be great for developing small (possibly embedded) websites.

Here's my somewhat ugly bullet point steps to the sample Camping Blog using NetBeans 6.0, JRuby and derby.

  • Install NetBeans 6 - M9 is the latest version at the time of writing (caveat emptor - I already logged a few bugs)

  • Unless you have Java 6, copy derbyclient.jar into {Net Beans}/ruby1/jruby-0.9.8/lib
    • If you're a Mac, you will find the {Net Beans} directory in "Show Package Contents"/Resources
    • You can get derbyclient.jar from your JDK directory if you did a full Java 5 installation, or you can get it in the full derby distribution from db.apache.org/derby


    • Install the camping gem (NetBeans Tools menu->Ruby Gems->Install New...)

    • Start the derby server in NetBeans (Tools menu->Java DB->Start)

    • Make a new "Ruby Application" project (be sure to call the main file blog.rb instead of main.rb)

    • Paste why's example blog.rb into your blog.rb

    • after the line that says require 'camping/session' add:
      gem 'ActiveRecord-JDBC'
      require 'active_record/connection_adapters/jdbc_adapter'

    • Create a file in your home directory called .campingrc with the following:
      database:
      adapter: jdbc
      driver: org.apache.derby.jdbc.ClientDriver
      url: jdbc:derby://localhost:1527/sample
      username: app
      password: app

    • In Project Properties->Run, add a configuration called camping, and add the path to the camping startup script into the ruby options field. I added:
      "/Developer/NetBeans 6.0 M9.app/Contents/Resources/NetBeans 6.0 M9/ruby1/jruby-0.9.8/bin/camping"
      , I haven't been able to simplify it with environment variables unfortunately.

    • Click the Run button (or use the Run menu)

    • Point your browser to http://localhost:3301/
    • And that's all there is to it! Note that instead of bothering to make a new database, I used one of the sample derby databases, but you can administer the derby databases in the Runtime window/tab of NetBeans.

      Sources:

      JRuby Tutorial - Going Camping
      The curse of camping

12:35 AM, 24 May 2007 by Mark Aufflick Permalink

Add comment