Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3239040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:55:24+00:00 2026-05-17T17:55:24+00:00

I have been working on a SWT-based project which is intended to be deployed

  • 0

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.

So far I have managed to tackle the exporting problem that arises due to the system-specific libraries SWT depends on (see relevant thread). 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:

$ 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.<init>(MarqueeSelectionTool.java:99)
   at org.gvt.MarqueeZoomTool.<init>(MarqueeZoomTool.java:16)
   at org.gvt.action.MarqueeZoomToolAction$1.<init>(MarqueeZoomToolAction.java:28)
   at org.gvt.action.MarqueeZoomToolAction.createTool(MarqueeZoomToolAction.java:28)
   at org.gvt.action.AbstractGEFToolAction.<init>(AbstractGEFToolAction.java:24)
   at org.gvt.action.MarqueeZoomToolAction.<init>(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.<init>(Unknown Source)
   at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
   at org.eclipse.swt.widgets.Display.<init>(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.<init>(Unknown Source)
   at org.eclipse.swt.graphics.Cursor.<init>(Unknown Source)
   at org.eclipse.draw2d.Cursors.<clinit>(Cursors.java:170)
   ... 16 more

I have checked a number of relevant threads: (Can’t get SWT Display on Mac OS X, Problems With SWT on Mac) as well as the UI Thread entry on the SWT FAQ and tutorials such as Bringing your Java App to Mac and Deploying SWT applications on Mac OSX.

It’s my understanding that the problem originates from thread handling on Mac OSX, and I should try to implement the JVM argument -XstartOnFirstThread at the execution. Is this right?

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 info.plist file, if so where in the package and how, otherwise how can I “conditionally” pass that argument to JVM at the time of execution?

Thanks in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:55:24+00:00Added an answer on May 17, 2026 at 5:55 pm

    Yes, you will definitely need -XstartOnFirstThread to get this working on Mac OS X. Since it’s a VM parameter, you can only specify it when launching your application, so detecting the OS from you code and setting it if it’s Mac OS X is not possible. The solution on the Eclipse site creates a proper Mac OS X My Application.app, which is platform specific and, again, not feasible in your case.

    However, I just tried running an Eclipse RCP application on Windows XP with the -XstartOnFirstThread argument specified, and it didn’t complain at all. This means that you can specify this argument in your JNLP file and presumably it will be ignored on all other platforms and picked up on Mac OS X.

    UPDATE: If for some reason -XstartOnFirstThread causes trouble on any platform, or you just want to Do The Right Thing, there is another possible solution. You could detect the user’s OS in the browser — assuming that the application is launched from a web page —, and supply a different JNLP for Mac OS X and other platforms.

    UPDATE 2: As pointed out in the comments, there is a tutorial on deploying SWT applications with Java Web Start. I simply launched the JNLP on Mac OS X (10.6.x), and it worked. Looking at the example JNPL I found the following:

    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+"
        codebase="http://www.eclipse.org/swt/jws/"
        href="controlexample.jnlp">
    <information>
          <title>Control Example</title>
          <vendor>eclipse.org</vendor>
          <homepage href="http://www.eclipse.org/swt/jws/" />
          <description>A demonstration of SWT Widgets</description>
          <description>Control Example</description>
    </information>
    
    <security>
        <all-permissions />
    </security>
    
    <resources>
        <extension href="swt.jnlp"/>
        <jar href="controlexample.jar" />
    </resources>
    
    <application-desc main-class="org.eclipse.swt.examples.controlexample.ControlExample" />
    </jnlp>
    

    Note the <extension href="swt.jnlp"/> line towards the end, pointing to the platform-specific SWT JNLP file (some parts omitted here):

    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+"
        codebase="http://www.eclipse.org/swt/jws/"
        href="swt.jnlp">
    <information>
          <title>SWT</title>
          <vendor>eclipse.org</vendor>
          <homepage href="http://www.eclipse.org/swt/jws/" />
          <description>SWT</description>
    </information>
    
    <security>
        <all-permissions />
    </security>
    
    <resources os="Windows" arch="x86">
        <j2se version="1.4+" />
        <jar href="swt-win32-windows-x86.jar" />
    </resources>
    
    ...
    
    <resources os="Mac\ OS\ X">
        <j2se version="1.5*" java-vm-args="-XstartOnFirstThread"/>
        <jar href="swt-carbon-osx-universal.jar" />
    </resources>
    
    <component-desc/>
    </jnlp>
    

    There it is towards the end of the file: the Mac OS X specific -XstartOnFirstThread argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a web services related project for about the last
I have been working on a web page and would like to load multiple
I have been working on a Swing based java program for a while now,
I have been working with Struts for some time, but for a project I
I have been working on developing some RESTful Services in Django to be used
I have been working on a new project for a little while and already
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have been working with a string[] array in C# that gets returned from
We have been working with CVS for years, and frequently find it useful to
I have been working on some legacy C++ code that uses variable length structures

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.