Java 7 doesn't seem to be correctly configured as you might expect when running IntelliJ 10.5 on Mac. This post explains how to set it up correctly.

I usually run IntelliJ IDEA 11 for most of my development, but my Mac at home hasn't yet been upgraded and is still running 10.5.4. I was using it tonight for a little sideline project I'm working on and needed to set up Java 7, which proved to be a little more involved than I'd hoped. Hopefully this ranks well in Google so others with the same issue can get some coherent (I hope) help in one place rather than a bunch of stackoverflow questions and other random links that are similar but not quite on the money.

Install Java 7

Firstly, you can download Java 7 from the Oracle (as of this writing, it's at JDK 7u7). Nothing special here. Download it. Install it. Done.

Once installed, you can find it at /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/ (or obviously whichever version you've installed). Sadly this bit of info wasn't made blatantly obvious, so I figured it'd be useful to know before you go filesystem hunting (and for me to come back to in the future when I've forgotten).

Configure IntelliJ IDEA 10.5

The latest version of IntelliJ (currently 11.1.3) didn't seem to have any problems configuring Java 7, so these steps weren't necessary for me. However, if you're running 10.5.4 (or I assume some other 10.x version) then you'll need to do some extra work.

First, you need to add Java 7 to your list of supported SDKs. You can configure that in Project Structure > Platform Settings > SDKs . Add your Java 7 SDK by selecting the appropriate /Contents/Home location (see the install location above), and you'll notice that the list of JARs on the classpath is significantly shorter than what you had for Java 6. And that's where the problems all started for me. It automatically included everything in the lib folder, but nothing under the jre/lib folder.

After much digging around, I found this page that highlights which JARs are required for IntelliJ (and Eclipse for that matter). Here's that list reproduced here for your sanity. Copy & paste away!

Hope that was helpful. If you notice any mistakes or omissions, please let me know so I can fix it for the next person that needs it.



Published

18 September 2012

Share

submit to reddit