Wednesday, August 6, 2008

Eclipse Ganymede on SoyLatte (Mac+Java6+Eclipse)

Mac has no Java 6. The Java 6 beta that Apple released is only 64-bit, which is no good for running Eclipse. Not only is this a major annoyance, it is a problem for developers that need to profile and take heap dumps of their applications.

Some time ago I found this post by Landon Fuller which supposedly launches Eclipse on SoyLatte. While I believe that Landon is a genius, it did not work for me. Well lately I've needed to take some heap dumps, so I tried again.

Here's what worked for me:

/Users/dgreen/Documents/java/soylatte16-i386-1.0.2/bin/java -server -Xms128m -Xmx1536m -XX:MaxPermSize=256m -Dosgi.requiredJavaVersion=1.5 -Dorg.eclipse.swt.internal.carbon.smallFonts -Djava.library.path=/Users/dgreen/bin/jnilib -cp /Applications/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar org.eclipse.equinox.launcher.Main -os macosx -ws carbon -arch x86 -showsplash -launcher /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -name Eclipse --launcher.library /Applications/eclipse/Eclipse.app/Contents/MacOS//../../../plugins/org.eclipse.equinox.launcher.carbon.macosx_1.0.100.v20080509-1800/eclipse_1114.so -startup /Applications/eclipse/Eclipse.app/Contents/MacOS/../../../plugins/org.eclipse.equinox.launcher_1.0.100.v20080509-1800.jar -data /Users/dgreen/Documents/workspace -launcher /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse -keyring /Users/dgreen/.eclipse_keyring -consoleLog -showlocation -vm /Users/dgreen/Documents/java/soylatte16-i386-1.0.2

I also had to extract all *.jnilib files from eclipse/plugins/org.eclipse.swt.carbon.macosx_3.4*.jar and copy them into /Users/dgreen/bin/jnilib
Finally, Eclipse running in a Java 6 VM on a Mac! Apple, time to get your Java act in gear.

Update 2008-08-21: SoyLatte 1.0.2 works for me, but 1.0.3 and OpenJDK 7 darwin packages posted here don't. If you find a solution, please let me know!

Update 2009-05-11: See this related article Eclipse 3.5 (Galileo) on Java 7

13 comments:

SwordAngel said...

Hi David. Thanks for sharing this tip for running Ganymede on Soylatte. I have been looking for instructions all over the place (and by that I mean Google :P).

I'm a little bit confused though. Are those 16 lines actually one single command line?

SwordAngel said...

Ok, I just tried the very long command line. It seems to work. I do get the IDE window, though the Terminal.app window would show errors from the JVM console output. I'm not sure if they are critical though: http://pastebin.ca/1166227

I have tried to add a "-vm" argument with my path to Soylatte JVM to the Info.plist, to see if I can avoid using the command line. Obviously that didn't work. I guess some more arguments are missing.

David Green said...

swordangel, you bet, it's all one command. I haven't figured out how to do this by altering the eclipse.ini, so for now I'm stuck with the command-line and Terminal. Please let me know if you figure it out!

Btw, the File->Switch Workspace menu item doesn't work for me, so I'm currently using the -data argument instead.

Anonymous said...

Hello,

I followed the instructions you wrote but I got that exception
java.lang.UnsatisfiedLinkError: no swt-carbon-3448 or swt-carbon in swt.library.path, java.library.path or the jar file

What do u mean exactly by extract all *.jnilib files? I guess that part is what's causing the problem.

Many thanks

cheers,

Hosam

David Green said...

Hosam,

By extracting all *.jnilib files I mean copying them from inside the jar file to the filesystem.

You should be aware that I've had problems on newer releases of SoyLatte and OpenJDK: it only works for me on SoyLatte 1.0.2.

Currently I've got an open question on the bsd-port-dev mailing list about this issue.

Good luck,

David

Anonymous said...

Many thanks for researching this! Let's hope that there will be some sort of a solution for SoyLatte 1.0.3+.

It was still printing out an UnsatisfiedLinkError regarding localfile_1_0_0 library. I found it in plugins/org.eclipse.core.filesystem.macosx_*.jar

After I put it in the same directory as the SWT libraries, Eclipse starts with no error messages at all.

-Gleb

David Green said...

Gleb, thanks for the tip!

Anonymous said...

Ok, so I was able to start Eclipse with SoyLatte 1.0.3. The problem was in the libjpeg.dylib library that comes with SoyLatte. When it's trying to load carbon, that library collides with the one from system framework, producing this exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/frank/sw/swt/libswt-carbon.dylib: dlopen(/Users/frank/sw/swt/libswt-carbon.dylib, 1): Library not loaded: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO
Reason: Incompatible library version: ImageIO requires version 1.0.0 or later, but libJPEG.dylib provides version 0.0.0

I managed to load Eclipse by renaming the libjpeg.dylib file in Soylatte (under jre/lib/i386.) I have no idea how much this has crippled Soylate, though.

The other thing is that all the .jnilib files we'd extracted from the jar need to be renamed to .dylib.

-Gleb

Anonymous said...

Some lines in the exception message were truncated, so here it is broken up into bite-size pieces:

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/frank/sw/swt/libswt-carbon.dylib:
dlopen(/Users/frank/sw/swt/libswt-carbon.
dylib, 1): Library not loaded: /System/Library/Frameworks/
ApplicationServices.framework/
Versions/A/Frameworks/
ImageIO.framework/
Versions/A/Resources/libJPEG.dylib
Referenced from: /System/Library/Frameworks/
ApplicationServices.framework/
Versions/A/Frameworks/
ImageIO.framework/
Versions/A/ImageIO
Reason: Incompatible library version: ImageIO requires version 1.0.0 or later, but libJPEG.dylib provides version 0.0.0

-Gleb

Ryan J. McDonough said...

How do you figure Mac OS X "has no Java 6" when it does? Also, why can't you run it under Java 5?

David Green said...

Ryan, at the time of this writing Mac OS X only had Java 5, with a beta release of Java 6. Of course, you can always run Eclipse using Java 5.

Now that Java 6 is available for Mac, it's only 64-bit. Until the cocoa port of SWT is available, Eclipse will only run on a Mac using a 32-bit VM.

For me running Eclipse on Java 5 works great, however until recently the Java 5 build for Mac was old with bugs that caused VM crashes when profiling. Also there have been many improvements to Java since Java 5 which I would like to use.

bijan said...

NICE!

Yonas said...

Sweet. This helped me.