JRuby

Guide

there're not many books about jruby, so check the official wiki

Notes

run ruby files

just jruby file.rb

use hash bang:

 #!/usr/bin/env jruby

irb

jirb to lanuch the ruby shell, to enable auto-completion, add this to ~/.irbrc

require 'irb/completion'

jruby also offers a gui one: jirb_swing, with drop-down box for auto-completion

gem and rake

run with -S

$ jruby -S gem list --local
$ jruby -S rake -T

JVM parameters

just like normal java, jruby -J-Xmx256m

to check if it works, try jruby -J-XX:+PrintFlagsFinal -J-Xmx256m -e 'true'|grep HeapSize

run with library

$ jruby -rjava -e "puts java.lang.System.get_property('java.version')"
Search Blog: