i think every time i have a list of three things, my natural tendency is to end it with “oh my!”. damn you l. frank baum!
we have a few macs at work to support a few different projects, and most of our projects are java-based. this year marks the end of life of java 5 (we’ll miss you!) and my introduction in to mac and java woes. it turns out steve jobs made some disparaging remarks against java, and now sun and java aren’t playing nice together. so much for cross platform, although at this points it is more an inconvenience than doom and gloom.
there are two basic problems. first, there is no 32-bit version of java 6 for the mac, so we had to install the 64-bit version. that normally wouldn’t be a big deal, except that for jni to work, the platform libraries need to be compiled to match the jvm, so all of our 32-bit libraries we built for one of our projects for which we leverage jni need to be recompiled for 64-bit support.
the second problem is eclipse, our development environment. evidently, it does not like the the mac java 6 implementation. good news! you can install java 6, but you can’t use your development environment in java 6! woot!
we did some searching around and came up with (mostly) a solution. here is what we did:
1. first, bite the bullet and install the 64-bit (and only) version of java on the mac.
2. next, make it your default JVM. To do this, use “Applications > Utilities > Java > Java Preferences”. drag the java 6 item to the top of both the applet and application lists. viola! default.
3. reboot.
4. to get eclipse to work, you’ll need to modify the plist file. mine was located in /Applications/eclipse/Eclipse.app/Contents/Info.plist. open it in an editor.
5. the default Info.plist file has a section near the top that shows you how to use a specific jvm for eclipse. i uncommented out the section for the 1.5 jvm.
6. launch eclipse. it should use the java 5 jvm and come up.
7. one last thing worth doing in eclipse is making sure you have both the 1.5 and 1.6 jres installed. to do this, in eclipse open th eclipse properties and navagate to “Java > Installed JREs”. click the add button and follow the prompts to add the path for any missing jres. you can also set the default jre here, and you should set the compiler compliance level under “Java > Compiler”.
the kicker is the jni side. for this to work, a few things need to happen.
first, you’ll need to recompile any libraries that you compiled to use with jni for 64-bit, if it isn’t already. in our case, we need the jpcap libraries. to do this, i had to modify the Makefile and specify the “-arch x86_64″ argument to the compiler. the other piece i had to check was to make sure that my jni references were pointing to the jni.h inside of the java 6 installation. it looks like that’s the bit that really counts for the whole jni thing.
of course, that didn’t work. well, it sort of worked. the jre isn’t complaining about the unsatisfiedlinkerror, but there is something still missing from the jpcap recompile so that some of the calls are not working. but we’ll get there.
ain’t technology fun?