Opening multiple Eclipse instances on Mac OS X
By Doug Simon on Jan 18, 2009
While I'm generally only working within one Eclipse workspace, I occasionally have the need to open more than one Eclipse instance. One good example for this need is when debugging a regression. In this case, it can be quite useful to run side-by-side debug sessions; one on my current code, the other on an earlier version that I know does not contain the bug. To do so, I simply want to create a copy of the earlier version (using 'hg clone -r <good version number>' since I'm using Mercurial) and bring it up in a new instance of Eclipse. This is straight forward on most systems but on Mac OS X, launching an application by double clicking its icon simply brings a running instance of the app to the foreground. So, to achieve the desired effect on Mac, one needs to resort to the command line:
open -n /Applications/eclipse/Eclipse.app
This forces a new instance of the app to start. In theory, this should be sufficient. However, as I found out in my case, there is (at least) one other complication that my present itself. I have JDK 6 installed on my Mac and due to the way I've configured my PATH variable, it's the default version of Java launched from a terminal with an unqualified use of the java command. It appears as though this is how the Eclipse launcher starts its embedded Java process. The problem then is that Eclipse is a 32-bit app and JDK 6 on the Mac is 64-bit only and not surprisingly the result is a crash. The trick is therefore to modify one's path to ensure the JDK 5 java command is the default on the command line:
env PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Commands:$PATH open -n /Applications/eclipse/Eclipse.app
I thought a better solution maybe to explicitly specify the JDK 5 java executable in /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini with the following line:
but that doesn't work for some reason.