title: Running SWT based, cross-platform jar properly on a Mac
body: <p>I have been working on a SWT-based project which is intended to be deployed as Java Web Start, and thus be used on multiple platforms. </p>
  
  <p>So far I have managed to tackle the exporting problem that arises due to the system-specific libraries SWT depends on (see relevant <a href="https://stackoverflow.com/questions/3959556/problems-with-loading-resources-during-execution">thread</a>). The resultant jar seems to work start fine on 32/64-bit linux and 64-bit windows, however execution fails on a Mac with the following output:</p>
  
  <pre><code>$ java -jar dist/test.jar 
  Adding { file:/Volumes/LaCie/ChiBE_Local/swt/swt-cocoa-macosx-x86_64-3.6.1.jar } to the classpath
  ***WARNING: Display must be created on main thread due to Cocoa restrictions.
  Exception in thread "main" java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
  Caused by: java.lang.ExceptionInInitializerError
     at org.eclipse.gef.tools.MarqueeSelectionTool.&lt;init&gt;(MarqueeSelectionTool.java:99)
     at org.gvt.MarqueeZoomTool.&lt;init&gt;(MarqueeZoomTool.java:16)
     at org.gvt.action.MarqueeZoomToolAction$1.&lt;init&gt;(MarqueeZoomToolAction.java:28)
     at org.gvt.action.MarqueeZoomToolAction.createTool(MarqueeZoomToolAction.java:28)
     at org.gvt.action.AbstractGEFToolAction.&lt;init&gt;(AbstractGEFToolAction.java:24)
     at org.gvt.action.MarqueeZoomToolAction.&lt;init&gt;(MarqueeZoomToolAction.java:20)
     at org.gvt.TopMenuBar.createBarMenu(TopMenuBar.java:113)
     at org.gvt.ChisioMain.createMenuManager(ChisioMain.java:617)
     at org.eclipse.jface.window.ApplicationWindow.addMenuBar(ApplicationWindow.java:235)
     at org.gvt.ChisioMain.main(ChisioMain.java:149)
     at org.gvt.RuntimeMain.main(RuntimeMain.java:14)
     ... 5 more
  Caused by: org.eclipse.swt.SWTException: Invalid thread access
     at org.eclipse.swt.SWT.error(Unknown Source)
     at org.eclipse.swt.SWT.error(Unknown Source)
     at org.eclipse.swt.SWT.error(Unknown Source)
     at org.eclipse.swt.widgets.Display.error(Unknown Source)
     at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
     at org.eclipse.swt.widgets.Display.create(Unknown Source)
     at org.eclipse.swt.graphics.Device.&lt;init&gt;(Unknown Source)
     at org.eclipse.swt.widgets.Display.&lt;init&gt;(Unknown Source)
     at org.eclipse.swt.widgets.Display.&lt;init&gt;(Unknown Source)
     at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
     at org.eclipse.swt.widgets.Display$1.run(Unknown Source)
     at org.eclipse.swt.graphics.Device.getDevice(Unknown Source)
     at org.eclipse.swt.graphics.Resource.&lt;init&gt;(Unknown Source)
     at org.eclipse.swt.graphics.Cursor.&lt;init&gt;(Unknown Source)
     at org.eclipse.draw2d.Cursors.&lt;clinit&gt;(Cursors.java:170)
     ... 16 more
  </code></pre>
  
  <p>I have checked a number of relevant threads: (<a href="https://stackoverflow.com/questions/1567144/cant-get-swt-display-on-mac-os-x">Can't get SWT Display on Mac OS X</a>, <a href="https://stackoverflow.com/questions/2746539/problems-with-swt-on-mac">Problems With SWT on Mac</a>) as well as the <a href="http://www.eclipse.org/swt/faq.php#uithread" rel="noreferrer">UI Thread entry on the SWT FAQ</a> and tutorials such as <a href="http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac3/" rel="noreferrer">Bringing your Java App to Mac</a> and <a href="http://www.eclipse.org/swt/macosx/" rel="noreferrer">Deploying SWT applications on Mac OSX</a>. </p>
  
  <p>It's my understanding that the problem originates from thread handling on Mac OSX, and I should try to implement the JVM argument <code>-XstartOnFirstThread</code> at the execution. Is this right?</p>
  
  <p>Assuming that my understanding of the problem is accurate, I am a bit confused as this software is intended to be cross-platform and run on javaws. Do I need to create an <code>info.plist</code> file, if so where in the package and how, otherwise how can I "conditionally" pass that argument to JVM at the time of execution?</p>
  
  <p>Thanks in advance,</p>