January 20th, 2012
evilmartini
The modern despot knows that taking away freedoms all at once results in revolution; but shaving freedoms away with the razor of law raises no alarm. Make no mistake, people who support curtailing the freedoms of others do so because it is in their best interest, not in yours. We have a choice: the next revolution can be a renaissance of ideas shared across a web of information that is open to everyone; or it can be a more traditional affair with pitchforks and a Bastile. But it cannot be both.
October 27th, 2011
evilmartini

Dive dive dive bar w/ @slackx and @adelcambre (Taken with Instagram at the Attic)

October 2nd, 2011
evilmartini

Friends with a view (@zombiejessica & @copiousfreetime) (Taken with instagram)

October 2nd, 2011
evilmartini

View across the park (Taken with Instagram at Jackson Square)

September 24th, 2011
evilmartini

Lismore castle #funconf (Taken with Instagram at Lismore Castle)

September 24th, 2011
evilmartini

Snooker & Whisky #funconf (Taken with Instagram at Lismore Castle)

August 22nd, 2011
evilmartini

Fire. Fire. Fire. (Taken with instagram)

August 5th, 2011
evilmartini

6mo Barrel aged Martinez (Taken with Instagram at The Passenger)

August 3rd, 2011
evilmartini

Ready for launch on tubes 1 - 4 (Taken with instagram)

July 25th, 2011
evilmartini

Un fsck’ing the JDK on OSX 10.7 Lion

27JUL2011: Quick update on this article after having a conversation with Mike Swingler @swingler . He indicates that the canonical way to set your JAVA_HOME environment variable is to place the following in the shell setup script of your choice:

JAVA_HOME=`/usr/libexec/java_home`

Which when run gives me: /Library/Java/JavaVirtualMachines/ - > 1.6.0_26-b03-383.jdk/Contents/Home

My particular issue was that the entire /JavaVirtualMachines/ directory was missing even after installing Java first using the “run a java command and it downloads” method, and second after downloading the apple JDK from their website. Let us be clear: I’m not advocating this as the way to install java; I’m merely indicating one way that I was able to get my JDK up and working in a very specific instance (which was shared by one other person AFAIK). So if the default setup works for you - great! It didn’t for me and it caused problems. Like all things on the interwebs, YMMV :)

A funny thing happend on the way to the upgrade. It would seem that OS X.7 decided that I no longer needed my Java subsystem. Now, before all the late adopters call me stupid for upgrading in the first round (you’re right) and before all the early adopters call me simple for not reading all the information about how Java wasn’t going to be included in 10.7 (I knew that, and thought I took appropriate precautions): let me qualify by saying I upgraded from 10.6. When I upgrade from one system to another, I might expect binary incompatibilities, but I don’t expect whole system based directories to go AWOL. Additionally, when I download and install the official developer SDK from my evil overlords at Apple…. and it still doesn’t work - I get a wee bit peeved. I pay the apple tax partially because this shit should just work. (I know that’s not the case, but I can dream, can’t I?)

The problem was first noticed when, after going through doing the time honored brew rebuild, I decided to update RVM and ensure that the compiled versions of ruby wouldn’t have some sort of strange compile time bug that would rear it’s ugly head. I also wanted to update my JRuby install to 1.6.3. All should be well… or should it?

Upon attempting to install JRuby 1.6.3 - I got the following

jruby-1.6.3 - #extracted to /Users/daksis/.rvm/src/jruby-1.6.3 Building Nailgun jruby-1.6.3 - #installing to /Users/daksis/.rvm/rubies/jruby-1.6.3 jruby-1.6.3 - #importing default gemsets (/Users/daksis/.rvm/gemsets/) /Users/daksis/.rvm/rubies/jruby-1.6.3/bin/jruby: line 357: -> /System/Library/Frameworks/JavaVM.framework/Home/bin/java: -> No such file or directory /Users/daksis/.rvm/rubies/jruby-1.6.3/bin/jruby: line 357: -> /System/Library/Frameworks/JavaVM.framework/Home/bin/java: - > No such file or directory

At this point, the eye quirks. At this point, I’ve done this often enough to know something is probably screwed up with the directory for $JAVA_HOME that is set it my shell. I’ve been bit by this before, so I do the deep check on the shell variable:

~ %echo $JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Home ~ %echo $JAVA_HOME | hexdump 0000000 2f 53 79 73 74 65 6d 2f 4c 69 62 72 61 72 79 2f 0000010 46 72 61 6d 65 77 6f 72 6b 73 2f 4a 61 76 61 56 0000020 4d 2e 66 72 61 6d 65 77 6f 72 6b 2f 48 6f 6d 65 0000030 0a
0000031 ~ %

I can’t remember where I got the “pipe to hexdump” trick from, but that can really be a life saver when shell variables have weird non visual characters in them.

It all looks good so let’s see what’s up with the directory:

~ %cd $JAVA_HOME cd: no such file or directory: - > /System/Library/Frameworks/JavaVM.framework/Home ~ (1)%

Say what? Unless I’m mistaken, the Framework that was there before I upgraded is no longer there…. :/ .

So a quick check: ..avaVM.framework %pwd /System/Library/Frameworks/JavaVM.framework ...avaVM.framework %ls Classes Frameworks Home Libraries Versions Commands Headers JavaVM Resources ...avaVM.framework %

show’s that there is indeed no home directory. Now I don’t remember if I added a symlink to “./home” or not, but it shouldn’t be too hard to find the home directory and link it there.

A quick check of the symlinks:

..avaVM.framework %ls -al total 64 . .. Classes -> Versions/CurrentJDK/Classes Commands -> Versions/CurrentJDK/Commands Frameworks -> Versions/Current/Frameworks Headers -> Versions/Current/Headers Home -> Versions/CurrentJDK/Home JavaVM -> Versions/Current/JavaVM Libraries -> Versions/CurrentJDK/Libraries Resources -> Versions/Current/Resources Versions ...avaVM.framework %

Okay, so let’s peek into Versions:

...mework/Versions %ls -al total 64 ...10 Jul 23 14:31 1.4@ -> CurrentJDK ...10 Jul 23 14:31 1.4.2@ -> CurrentJDK ...10 Jul 23 14:31 1.5@ -> CurrentJDK ...10 Jul 23 14:31 1.5.0@ -> CurrentJDK ...10 Jul 23 14:31 1.6@ -> CurrentJDK ...10 Jul 23 14:31 1.6.0@ -> CurrentJDK ...272 Jul 23 14:31 A/ ...1 Jul 23 14:31 Current@ -> A ...59 Jul 23 14:31 CurrentJDK@ -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

A quick peek in “A” shows us some real directories…

...work/Versions/A %ls -lF total 72 drwxr-xr-x 42 root wheel 1428 Jul 23 14:31 Commands/ drwxr-xr-x 4 root wheel 136 Jul 2 10:31 Frameworks/ drwxr-xr-x 14 root wheel 476 Jul 23 14:31 Headers/ -rwxr-xr-x 1 root wheel 103472 Jul 23 14:31 JavaVM* drwxr-xr-x 34 root wheel 1156 Jul 23 14:31 Resources/ drwxr-xr-x 3 root wheel 102 Jul 23 14:31 _CodeSignature/ ...work/Versions/A %

But I’ll spare you the long story, neither Commands nor Frameworks are the directories that we’re looking for.

Heading back up to "/System/Library/Frameworks/JavaVM.framework/Versions" we can see that the directory CurrentJDK@ is really just a symlink to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents so it seems like this is the next place we should look. Changing over to the directory - here’s what we find:

...mework/Versions %cd /System/Library/Java/
...em/Library/Java %ls -lF total 0 drwxr-xr-x 19 root wheel 646 Jul 23 14:31 Extensions/ -rw-r--r-- 1 root wheel 1062 Jul 8 01:36 JavaConfig.plist drwxr-xr-x 5 root wheel 170 Jul 8 01:38 Support/ ...em/Library/Java %

Ummm, where the directory that we’re supposed to be symlinked to?

It would seem that the JDK itself is missing. Seeing as I downloaded the developer SDK from the mothership itself, it would seem like this was an unlikely oversite on the part of the peeps at apple. I decided to crack open the SDK included on the “javadeveloper_for_mac_os_x_10.7__11a511.dmg” that I downloaded from the ADC downloads center.

At this point I have to give a nod to a great tool Pacifist - it’s a utility that allows you to dissect a downloaded .pkg file and see what’s installed by the package itself. Additionally, it allows you to dissect the package as if the package was just a normal archive. (Which it very well might be - if someone knows how to do this via XCode for a package you didn’t create, please let me know, especially via the command line.)

Eureka! inside the JavaDeveloper.pkg there’s another package called “Contents of JavaForMacOSX10.7Dev.pkg”. The directory structure of this package looks exactly like what’s missing from the /System/Library/Java/ folder. Extracting the package to the file system and examining the package in the finder shows us that this looks like a pretty good candidate for the SDK.

Structure of the Java Development Package

So it seems pretty simple - in order to restore the JDK on the machine, it looks like you need to do the following. (I cut and paste this from my .history file, so YMMV - but you get the idea.)

cd /System/Library/Java/ sudo mkdir JavaVirtualMachines cd JavaVirtualMachines sudo cp -r ~/{WHERE_YOU_EXTRACTED_THIS_PACKAGE_TO}/1.6.0_26-b03-383.jdk . sudo chown root:wheel -R 2.6.0_26-b03-383.jdk sudo ln -s 1.6.0_26-b03-383.jdk 1.6.0.jdk

Now deep inside my .zshrc file, there was a commented out entry that began as follows. You might need this, you might not, but I’ll include it for completeness. I’ve never needed anything other than $JAVA_HOME to be set correctly.

declare -x JDK_HOME= -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

Now when I go to build JRuby:

~ %rvm install jruby jruby-1.6.3 - #fetching jruby-1.6.3 - #extracted to /Users/daksis/.rvm/src/jruby-1.6.3 -> (already extracted) Building Nailgun jruby-1.6.3 - #installing to /Users/daksis/.rvm/rubies/jruby-1.6.3 jruby-1.6.3 - #importing default gemsets (/Users/daksis/.rvm/gemsets/) Copying across included gems Building native extensions. This could take a while... Successfully installed jruby-launcher-1.0.7-java 1 gem installed ~ %

So at the end of all of this…. it would appear that even when you download and install the Java developer package, that the JDK itself is not installed. Kind of a pain in the ass to have to figure this out the hard way.

Like all such information, use this at your own risk blah blah blah. I’d really be interested to be proven completely wrong on this one and have someone tell me that I missed a checkbox on the install somewhere. Please let me know if this works for you, or if it doesn’t. I don’t want to be spreading more FUD about Java on OSX than necessary …. or warranted ;).

Loading tweets...

@daksis

One geeks quest to write good code, eat better food, and consume every drop of whisky he can get his hands on