There is more than one way to experiment with Ruby. JRuby is a mature version of Ruby written for the Java Virtual Machine. This gives you a great deal of platform independence, since JRuby will comfortably run anywhere that Java runs. It also provides you with access to Java’s huge standard library. I thought I would take a little time to examine the JRuby implementation, which is nearing a 1.0 release.
We need Java before we can do anything with JRuby, though. I already have 1.6.0 installed on my machine. If you don’t have Java, now is the time to get it.
With Java safely installed on our machine, it is time to download and install JRuby. The download is a simple archive file — most Windows users will want to go for the zipped version, since that is best understood by their system. I grabbed the tarred and gzipped archive of the binaries for myself. An automatic installer would be nice, but it isn’t the sort of thing that’s going to stop me.
The archive contains a
bin folder containing several interesting files. The ones which interest me most are
gem. Supporting Ruby Gems means that we can install from the standard Ruby repositories. I need to put this folder at a sensible location on my system, and then put that location on my path.
I got that right, so I can safely add the
export PATH line to my
$HOME/.bash_profile when I feel like it.
There’s probably a quick way to do it in Windows as well, but here’s what I know how to do.
- Open the Control Panel
- Select “System”
- Select “Advanced system settings”
- Select “Environment Variables” button.
- Select “Path” from System Variables if you have admin privileges, otherwise from User variables.
- Click “Edit”.
- At the beginning of the “Variable value” field, put the location of
- Click “Ok” until all those lovely dialog boxes go away.
Now you should be able to access the JRuby commands from any console. The Windows command prompt is accessible via the Start Menu, under Accessories.
I want to make sure the Java interface works, so I’ll fire up the
jirb shell —
— and test with a quick Swing “Hello World” dialog borrowing from the Hello World Repository.
JRuby “Hello World”
That popped up a simple “Ok” style dialog box with the message “Hello World!”.
Added to vault 2024-01-15. Updated on 2024-02-01