Collecting my attempts to improve at tech, art, and life

Reinstalling JRuby

Tags: blogspot

I’m still getting everything back together after the iMac upgrade fiasco. JRuby, my favorite Ruby implementation, is still missing. I think I’ll fix that now.

# ~/.bash_profile
export JRUBY_HOME="/usr/local/jruby"</strong>
# OS X is normally conservative about paths, while I am generous about them.
export LOCALBINS=/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/X11R6/bin

if [ -r ~/.bashrc ]; then
    . ~/.bashrc

Source the file and test my path …

$ . ~/.bash_profile
$ which jruby
$ which gem

Test with the sample code from Getting Started on the JRuby wiki.

require "java"

include_class "java.util.TreeSet"

puts "Hello from JRuby"
set =
set.add( "foo" )
set.add( "Bar" )
set.add( "baz" )
set.each { |v| puts "value: #{v}" }

Run it.

$ jruby call_java.rb

Wait a very long time (why does Java startup have to be so slow on our Mac and how the heck can I make it faster? It’s one thing that’s significantly worse on our Mac compared to my PC). Eventually see:

$ jruby call_java.rb
Hello from JRuby
value: Bar
value: baz
value: foo

Excellent, it worked. It’s 2:46 now. I better post this and go to bed.

Added to vault 2024-01-15. Updated on 2024-01-26