17 June 2011

Building and Running OpenJDK 7 on Mac OS X - A Breeze

Preparing a little for the Adelaide JUG meeting yesterday, where Java SE 7 was going to be the topic of discussion, I finally thought it was time to grab the OpenJDK 7 source, get it built and working on my Mac.

http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port

After checking off the pre-reqs, the process was as simple as following the small set of very clear instructions on the Wiki page.

The only small side excursion I had was that my bash environment had a JAVA_HOME env var set, which aborted the build at one point.  Unsetting that and restarting the build, it then ran flawlessly for about 30mins before out popped a shiny new Open JDK 7 build.

Having never manually installed a JDK on my Mac (Apple updates have served me well) the instructions for how and where to install it was very helpful. And so simple! Particularly with how it results in the new JDK being visible to the /usr/libexec/java_home utility:

sbutton:~ $ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
1.6.0_24-b07-334, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_24-b07-334, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.7.0, x86_64: "OpenJDK 7" /Users/sbutton/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
1.7.0, i386: "OpenJDK 7" /Users/sbutton/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Voila!

sbutton:~ $ export JAVA_HOME=`/usr/libexec/java_home  -v 1.7`
sbutton:~ $ java -version
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-sbutton_2011_06_16_11_39-b00)
OpenJDK 64-Bit Server VM (build 21.0-b15, mixed mode)  

 
Now looking forward to trying out some of the new language features with NetBeans 7.0.


All in all, a total breeze! Kudos to the OpenJDK Mac porters group.

4 comments:

Anonymous said...

Great!! I was looking to do the same. Hoz NetBeans running in JDK7 for Mac?

Buttso said...

Hi --

NetBeans seems to work very well in the limited uses I've made of it so far with JDK7.

I did also find the other day a link to a prebuilt binary for Mac, from this page here:

http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port

Which points to:

http://code.google.com/p/openjdk-osx-build/downloads/list?q=label:Featured

Saves the hassle of building it yourself. Not sure how I missed it the first time, but it's good to see this is available.

-steve-

Unknown said...

You can also download latest version of OpenJDK for OS X Lion at http://code.google.com/p/openjdk-for-os-x-lion/

Buttso said...

Thanks Stefan.