Mark Mzyk | August 24, 2011
I currently have a project that I’m evaluating using JRuby for. The first step in the evaluation is of course to set everything up. While I could have installed JRuby and let it run with the version of Java already available on Mac OS X Lion, I opted to be on the edge. That means installing the latest OpenJDK Mac OS X port of Java 7 and installing JRuby on top of it.
These are the directions of how I did that.
These steps can be found in other places, but my hope is that by collecting them all in one place I make it easier for others.
First stop, Java.
Java 7 is not yet officially out for Lion, but it is possible to install a Mac OS X port early release version without too much trouble.
The directions are available on the OpenJDK Mac OS X Port page.
First make sure you meet the prerequisites, such as having a 64 bit capable machine, having Lion, having the latest Xcode installed (Version 4.1, available through the Mac app store for free).
Once you’ve verified the prerequisites and installed Xcode 4.1 if you need it, you’ll need to download Apple’s preview of Java 7. This doesn’t install Java 7, but it is necessary so that you have the proper APIs for Java 7 to work on the Mac.
To download it, go to connect.apple.com.
You will need to log in using your Apple Id and password. You can register if you don’t have one.
Once in, navigate to the Java section. You’ll then want to download the latest disk image for Lion, which as of this writing is Java for 10.7 – 11M3504 (Disk Image).
Once the download is complete, run the disk image and install it.
Next you’ll need to follow further directions from the Mac OS X Ports page, found here.
The directions will tell you how to install a preview version of Java 7 on Lion. You can either build it from source or download an unofficial build. I opted to download the latest unofficial build, which is OpenJDK-OSX-1.7-universal-20110822.dmg at the time of this writing.
Once downloaded, install it.
Now Java 7 is on your system, but it won’t be the default Java. To make it the default Java, launch:
and drag both of the OpenJDK 7 entries to the top of the list. Then close the Java Preferences app. Java 7 is now installed on your system and is the default.
To make sure Java 7 is the default, launch a terminal and run
You should see output that looks similar to this:
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-b00)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
It’s onto JRuby.
Download the latest JRuby from jruby.org (as of this writing, it is 1.6.4).
I downloaded the tar ball. Extract it. It will place a jruby-1.6.4 folder wherever you extracted it to.
Move the folder to the location you want it on your system, if it isn’t already there.
Add the bin folder from the jruby folder you extracted to your system path. Good directions can be found at Hathology.com. Note that those directions modify the path for every user on the system, not just a single user.
Once that is done, close and restart any terminals you have open. Then type
jruby -v and you should see this:
jruby 1.6.4 (ruby-1.8.7-p330) (2011-08-23 17ea768) (OpenJDK 64-Bit Server VM 1.7.0-internal) [darwin-x86_64-java]
Success. You’re now running JRuby with Java 7 on Mac OS X Lion.
Since the Java 7 isn’t an official version, I can’t promise there won’t be bugs or other weirdness, but that’s the fun of living on the edge.
Filed in: General.