Tag Archives: Eclipse

Eclipse, OSX and JDK 1.7

Despite being a massive Mac fanboi I am the first to admit that as soon as you start going a little off piste with OSX you run into problems that require technical knowledge to fix. Java development on the Mac falls into the category of off piste and it has always been more than a little fun getting things set up.

Now that Oracle are providing the JDK it seems that things no longer live quite where they do which left me scratching my head when trying to get Eclipse working with JDK 1.7.

Installing JDK 1.7 is easy, go to the Oracle download page, grab the 64bit OSX DMG, open, run, job done.

$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Now to tell Eclipse where the JDK is:

$ ls -l `which java`
lrwxr-xr-x  1 root  wheel  74 24 Oct 15:37 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Great… except Eclipse doesn’t recognise /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/ or /System/Library/Frameworks/JavaVM.framework/Versions/Current/ as a valid JDK location.

A bit of Googling I discovered the magic java_home command.

$ /usr/libexec/java_home -v 1.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

Giving that directory to Eclipse made it happy and I’m now able to use an up to date version of Java for my code.

Maven and Eclipse

Yesterday’s issue with Maven turned out to be a little more severe than just not having an Internet connection. Not only could Eclipse not create my new project, it couldn’t build an existing one. This problem persisted even with an Internet connection. From the command line everything worked though.

After fiddling about with a few things I tried a software update for Eclipse. It failed updating GWT. The last time I used eclipse on my laptop I was buggering about with Google Web Toolkit and Maven. Given the failure to update maybe I’d broken something. I uninstalled GWT. No joy.

Finally I stumbled across something on Google that suggested I blow away a large chunk of my local Maven repository, rebuild clean from the command line, refresh the Eclipse project and run Maven -> Update from within the project. That worked.

As far as I can work out I had newer version of the jars in my repository than Eclipse wanted and, for whatever reason, it wasn’t downloading the versions I needed. The command line was happy with the version I had. By deleting and updating it obviously downloaded versions that everyone was happy with. And people wonder why I like Ant.