10/21/2009

Mac OS X: Using IntelliJ IDEA on 64bit JDK6

UPDATE 2:
The retail version of IntelliJ Idea 9 uses the JDK6 32bit by default on Snow Leopard (in contrast with the betas which were using JDK6 64bit).
The article has been updated to reflect this.

IntelliJ Idea 9.0 - Mac OSX 10.6 Snow Leopard

The default installation of IntelliJ IDEA 9.0 uses JDK6 32bit on Mac OSX 10.6 "Snow Leopard". With a little configuration we can force it  to use the 64 bit JDK6, which is also part of the operating system.

After you installed IntelliJ IDEA, Cmd+click on the IDEA launcher-icon to open it in Finder. Ctrl-click on the IntelliJ IDEA icon and choose Show Package Contents. Select Contents and right-click Info.plist. Select Open with -> TextEdit. This brings up the file in the text editor.

Do a search (CMD+f) on the string JVMArchs. You'll find the following entry:

<key>JVMArchs</key>
<array>
  <string>i386</string>
  <string>x86_64</string>
  <string>ppc</string>
</array>

Put the x86_64 entry on top (e.g. swap the i386 and the x86_64 lines), save the file (CMD+s) and close TextEdit (CMD+q). If you restart Idea, you'll see it is using the 64bit JDK if you check it in the IntelliJ Idea->About.

You can also check if a given process is 64bit in Applications->Utilities->Activity Monitor. Check out the last column called Kind.

IntelliJ Idea 8.0, 9.0 - Mac OSX 10.5 Leopard

In contrast, Idea uses JDK5 on MacOS X 10.5 "Leopard", and that's 32bit only. Again just a little configuration and we can force it to use the 64bit JDK6.

After you installed IntelliJ IDEA, CMD+click on the IDEA launcher-icon which brings up the entry in Finder, now right-click (or ctrl-click) on the IntelliJ IDEA icon and choose Show Package Contents. Select Contents and right-click Info.plist. Select Open with -> TextEdit. This brings up the file in the text editor.

Do a search (CMD+f) on the string JVMVersion. You'll find the following entry:
<key>JVMVersion</key>
<string>1.5*</string>
Change the 1.5* to 1.6*, save the file (CMD+s) and close TextEdit (CMD+q). Since the JDK6 in Leopard is 64-bit only, we don't have to touch the JVMArchs section.

Start IDEA and check in About IntelliJ IDEA if it is indeed using the 64bit JDK6.

IntelliJ Idea 8, 9 betas: if IntelliJ does not start anymore, and honors us with a [JavaAppLauncher Error] unable to find a version of Java to launch in the log file, we have to replace the launcher with a 64bit executable. Open a terminal:

cp /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub64 /Applications/Maia-IU-90.94.app/Contents/MacOS/idea

Replace Maia-IU-90.94 with the proper name of your application - I was using a developer preview of IntelliJ IDEA 9, but this same method works for version 8 as well.

32bit or 64bit?

To me IntelliJ Idea seems more responsive on 64bit JDKs. I'm wondering if you consider it faster as well? If you are developing for JDK6 on Leopard you should use similar amount of memory now (the 64-bit JDK footprint is bigger but there's only one copy of the JDK in memory), and - as a question of personal taste - the display looks nicer since JDK6 uses the native font smoothing style of OSX (a mixture of regular antialiasing and subpixel rendering), whilst JDK5 uses plain anti-aliasing without subpixel rendering. There are some comments online about memory leaks using JDK6, but personally I didn't experience this.

Happy developing using this great tool!











7 comments:

  1. My 10.6.1 copy doesn't have
    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub64
    but only
    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub

    Any idea?

    ReplyDelete
  2. I'm using 10.5.6 at the moment, but will probably upgrade soon to Snow Leopard as well. I'll leave a comment here if I can find out something with 10.6.

    ReplyDelete
  3. I'm using Maia-IC-90-96 and this use for default the key JVMVersion to 1.6* but this run in 32 bits mode.

    For change this behavior I has change the order in the JVMArchs order from i386, x86_64, ppc to x86_64, i386, ppc in this way:

    <key>JVMArchs</key>
    <array>
    <string>x86_64</string>
    <string>i386</string>
    <string>ppc</string>
    </array>

    ReplyDelete
  4. Sorry, I has omited that I'm using Maia-IC-90-96 under Snow Leopard.

    ReplyDelete
  5. I have just installed IntelliJ Idea 9 Beta (90.193) on a freshly installed Snow Leopard. In my my Info.plist I have 1.5* and i386 as top-priority.

    Still, in IntelliJ Idea->About IntelliJ Idea, my JDK is reported as 1.6.0_15 64-Bit Server VM, so I presume Idea is using the proper, 64bit 1.6 JDK under Snow Leopard without any further configuration.

    thegeekinside, are you sure you are using 32 bit JDK? Or is it possible that this behaviour has changed from 90.96 to 90.193?

    ReplyDelete
  6. nodje, if you do a

    file /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub

    in terminal, you will see that the executable has the 64 bit binary executable as well:

    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub: Mach-O universal binary with 3 architectures

    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub (for architecture x86_64): Mach-O 64-bit executable x86_64

    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub (for architecture i386): Mach-O executable i386

    /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub (for architecture ppc7400): Mach-O executable ppc

    So you could copy that, right, but as it turns out it is not needed anymore since IntelliJ Idea 90.193 is using 64bit JDK6 on Snow Leopard by default.

    ReplyDelete
  7. Thank you! I wish the Idea engineers would do a better job with this issue.

    ReplyDelete