views:

172

answers:

2

I can't get a swt application to work on Mac OSX Snow Leopard.

Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-cocoa-3557 or swt-cocoa in swt.library.path, java.library.path or the jar file
    at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
    at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
    at org.eclipse.swt.internal.cocoa.NSThread.isMainThread(Unknown Source)
    at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
    at com.astrobetty.geotag.Hello.main(Hello.java:12)

I have added -Dswt.library.path= and -Djava.library.path statements to the "VM arrguments" hand have also tried setting them as variables in the "environment" section of the Eclipse run configuration page.

I've verified that my .jar file is at the path I specify. If I look inside the .jar, it seems to contain these libraries:

     102 Feb 12 13:21 META-INF
     183 Feb 12 13:21 external.xpt
   37104 Nov 17  2009 libswt-awt-cocoa-3557.jnilib
  287228 Nov 17  2009 libswt-cocoa-3557.jnilib
  548252 Nov 17  2009 libswt-pi-cocoa-3557.jnilib
  313420 Nov 17  2009 libswt-xulrunner-cocoa-3557.jnilib
    136 May 23 22:19 org
     13 Feb 12 13:21 version.txt

Any ideas on how to get this to work? Is it possible at all?

I added swt as a "dependent project" as detailed here

http://www.eclipse.org/swt/eclipse.php

and it does seem to find the .jar files at edit time (I get syntax checking, etc, for the swt classes and methods.)

+1  A: 

Adding a 'dependent project' works in the IDE, but not for deployment. You're probably in the OSGi environment... I'm not sure how you're deploying the product, but if you create a .product file (New-->Product Configuration), include your plugins and the SWT plugins and then export using that product and I'm sure it'll work out for you.

arcticpenguin
A: 

I gave up on using SWT after about 40 man-hours of trying to make it work. I get the feeling that Java for desktop apps is more FUD than reality.

ראובן