Friday, September 11, 2009

Java6 and IntelliJ on MacOS X

It's the third time now that I'm going through this, and each time I'm forgetting something...

The main problems I'm having are:
  1. How to enforce Java6 64bit JVM as the default on MacOS?

  2. How to make IntelliJ use it?

  3. How to make Safari (and may be one day Firefox) use it

I know I'm loosing SWT, and many soft (like NetBeans and IntelliJ) enforce Java 5 has hard coded default on the Mac, but I'm developing in Fan and the IntelliJ Fan Plugin, and Java 6 is kind of a must :)

So, here is what I do:
On each update of Java6 from Apple

  1. As root I go under:
    cd /System/Library/Frameworks/JavaVM.framework/Versions/

  2. There should be a symlink: CurrentJDK -> 1.5

  3. Then I change the link:
    rm CurrentJDK && ln -s 1.6 CurrentJDK

On each update of IntelliJ

  1. Download the idea-XXX.dmg, the idea-XXX.tar.gz (64 bit not the jdk15 version), and I hope JetBrains will start giving dmg files for the 64 bit JVM, because it's big downloads :(

  2. Copy the "IntelliJ IDEA" folder from DMG to Applications. I have /Applications/IntelliJ and /Applications/NetBeans with the versions I used, it helps when I'm messing up :)

  3. Do a copy of it under "IntelliJ IDEA" for backup and to be able to compile IntelliJ plugin for 1.5

  4. Extract the idea-XXX.tar.gz under /Applications/IntelliJ

  5. Copy all the jar files from idea-XXX to "IntelliJ IDEA". I do as root under idea-XXX:
    find . -name "*.jar" -exec cp \{\} ../IntelliJ\ IDEA\\{\} \;

  6. Change the "IntelliJ IDEA" with:

    <string>-Xms400m -Xmx1248m -XX:MaxPermSize=192m -XX:PermSize=192m -Xbootclasspath/a:../lib/boot.jar -ea</string>

  7. Here usually I try to run "open /Applications/IntelliJ IDEA" and I get:
    LSOpenFromURLSpec() failed with error -10810 for the file /Applications/IntelliJ/IntelliJ IDEA

  8. The the solution is (as root):
    cp /System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub64 /Applications/IntelliJ/IntelliJ\ IDEA\

For Safari and Firefox, I still don't manage to do it!

Hope I won't have to do this too much in the future, once everyone agrees on JDK 1.6 64 bits as Mac OS X default.