jruby with 1.9 mode as the default with rvm

Thanks to [recent commits](https://github.com/wayneeseguin/rvm/compare/249d08df…2388c1af) from [Wayne](https://github.com/wayneeseguin), you can now pass a build flag when install jruby with rvm and it will build jruby instead of downloading a prebuilt copy. Make sure you `rvm get head && rvm reload` first. Then we can install jruby with 1.9 mode as the default:

rvm install jruby -C -Djruby.default.ruby.version=1.9

And if you want to use jruby-head:

rvm install jruby-head -C -Djruby.default.ruby.version=1.9

Speeding up jruby with nailgun

I had always wondered why when I installed jruby using rvm it always built something called [Nailgun](http://www.martiansoftware.com/nailgun/) but I never bothered to search about it.

That was a mistake.

Nailgun is an amazing idea that greatly speeds up the start up time of the JVM and subsequently: jruby.

#### Without Nailgun

$ time jruby -e ”

real 0m1.336s
user 0m2.608s
sys 0m0.205s

#### With Nailgun

$ time jruby –ng -e ”

real 0m0.265s
user 0m0.001s
sys 0m0.003s

As you can see, nailgun reduced the start up time for jruby by 500%. Now you may be asking “How do I get started using nailgun?”. Well, if you are using rvm then all you need to do is enable the `after_use_jruby` hook which will start up a nailgun server for you.

chmod +x “$rvm_hooks_path/after_use” “$rvm_hooks_path/after_use_jruby”

And that’s all you need to do. `rvm jruby` or `rvm use jruby` will now start up a nailgun server if there isn’t one running and it set the `–ng` switch for all jruby runs.

If you aren’t using rvm, you will have to compile nailgun and start up a nailgun server with `jruby –ng-server`. Now whenever you run jruby you just add the `–ng` switch and it will use the nailgun server.
You may want to `export JRUBY_OPTS=”–ng”` to set the switch for all jruby runs.