For Widgetbox
I was recently tasked with investigating a new Java memcached
client called xmemcached
.
Things were going smoothly (except that the xmemcached documentation is written mostly in Chinese)… But then I hit a bump in the road: the xmemcached JAR file was compiled for JDK 1.6
.
Up until this point, all our code was using JDK 1.5, and we had only vague plans to eventually upgrade to JDK 1.6. Upon discussion, I’m just gonna work on the 1.6 stuff in a branch until we get the rest of the development team and operating environments up to a JDK 1.6 standard.
So, I went about upping my chosen JDK via the "Java Preferences
" dialog.
Now, I saw something like this:
$ java -version java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
Awesome. That’s exactly what I wanted!
But hold the phone, I was also getting this:
$ mvn -v Maven version: 2.0.9 Java version: 1.5.0_16 OS name: "mac os x" version: "10.5.6" arch: "i386" Family: "unix"
So, I did some digging. With some hints
, I found that the executable /usr/bin/mvn uses the symlink "CurrentJDK" to figure out which JDK to run, and the "Java Preferences" panel doesn’t update that when you change JDKs. (Dumb!)
So, here’s how I fixed it:
$ cd /System/Library/Frameworks/JavaVM.framework/Versions/ $ ls -la ... lrwxr-xr-x 1 root wheel 5 Sep 29 2008 1.5 -> 1.5.0 drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.5.0 lrwxr-xr-x 1 root wheel 5 Sep 29 2008 1.6 -> 1.6.0 drwxr-xr-x 8 root wheel 272 May 6 2008 1.6.0 lrwxr-xr-x 1 root wheel 3 May 12 18:18 CurrentJDK -> 1.5 ... $ sudo rm CurrentJDK $ sudo ln -s 1.6 CurrentJDK
Now, I am seeing the environment I want:
$ ls -la ... lrwxr-xr-x 1 root wheel 5 Sep 29 2008 1.5 -> 1.5.0 drwxr-xr-x 8 root wheel 272 Feb 21 2008 1.5.0 lrwxr-xr-x 1 root wheel 5 Sep 29 2008 1.6 -> 1.6.0 drwxr-xr-x 8 root wheel 272 May 6 2008 1.6.0 lrwxr-xr-x 1 root wheel 3 May 12 18:18 CurrentJDK -> 1.6 ... $ mvn -v Maven version: 2.0.9 Java version: 1.6.0_07 OS name: "mac os x" version: "10.5.6" arch: "x86_64" Family: "mac"
Thanks for the solution! This helped me a great deal.
Comment by Marc — 12 August 2009 @ 01:56
Thanks for posting that.
I had exactly the same problem, your solution was spot on.
Comment by Simon — 28 November 2009 @ 22:43