tags:

views:

231

answers:

3

Can someone tell me where I can find the executeable "java_swt"?

I see multiple sites that say it is embedded in eclipse, and other sites say it is shipped with Mac swt drops. I have the zip file for a mac called "swt-3.5M6-carbon-macosx.zip" and i have the eclipse IDE installed on my test mac machine and windows machine. But i cannot find this executeable which i need to run an swt app smoothly on mac os x.

Any help would be appreciated. Thanks.

A: 

I don't know what this 'java_swt' is, I don't think that Eclipse currently ships such a thing. The SWT FAQ might help.

If you are just running normal java + swt, you can probably still use the eclipse executable. You will need a jar that has a manifest specifying the Main-Class header. As well, in addition to the normal static main method, you will need a non-static run method (this is what the executable will actually call):

int run(String [] args);

Since you won't have the normal eclipse layout, you will need the eclipse launcher shared library (normally in plugins/org.eclipse.equinox.launcher.<ws>.<os>.<arch>/eclipse_1206.so).

Also, because your jar would not contain the equinox classes for handling the splash screen, you should probably explicitly turn that off.

The command line would be something like:

eclipse -nosplash --launcher.library eclipse_1206.so -startup my_program.jar

You can put those command line arguments into an eclipse.ini beside the executable, each argument goes on a separate line. If you rename the executable, rename the .ini to match.

Andrew Niefer
Apparently the "java_swt" launcher was created due to threading issues between swt and mac os x. This launcher syncs the threads. I google it and so many examples use this saying its included in mac swt drops. It is in the bug list for eclipse swt.
Ah, it is obsolete, I found https://bugs.eclipse.org/bugs/show_bug.cgi?id=135854#c2. Also, http://www.eclipse.org/swt/macosx/.Note also that the eclipse launcher (since 3.3) uses the JNI invocation API to start java on the mac. It does this on the first thread so -XstartOnFirstThread is essentially implicit in using the eclipse launcher. There is actually the inverse argument --launcher.secondThread if you want to use the eclipse launcher with AWT.
Andrew Niefer
+1  A: 

Instead of looking for this java_swt, I instead changed my bash executeable the application bundle launches to references my Jar file directly. The swt jar is in the bundle with my app jar, as well as the jni libraries under a dll folder. folder structure is:

|Contents
    Info.plist
    PkgInfo
    |MacOS
        bashExec
    |Resources
        myApp.icns
        |Java
            |dll
                libswt-carbon-xxxx.jnilib
                libswt-pi-carbon-xxxx.jnilib
            myApp.jar
            swt.jar

The bash shell is pretty basic and solves the threading problem between swt and mac with the "-XstartOnFirstThread" call. Here is the bash shell (the pound sign isnt displayed in the first line before the '!'):

#!/bin/sh

BASEDIR='dirname "$0"'

exec java \
-XstartOnFirstThread \
-Dorg.eclipse.swt.internal.carbon.smallFonts \
-Dorg.eclipse.swt.internal.carbon.noFocusRing \
-jar "$BASEDIR/../Resources/Java/myApp.jar"
A: 

SWT exists as a toolkit. Might I suggest you get the RCP version of Eclipse - may make your life a bit easier

PSU_Kardi