Profile Image

What is Java MacOS Start On First Thread: -XstartOnFirstThread?

What is Java MacOS Start On First Thread: -XstartOnFirstThread? Have you used this JVM argument before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvm-argument

  • xstartonfirstthread

  • startonfirstthread

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky


This option is only available on MacOS.

• -XstartOnFirstThread


The -XstartOnFirstThread option is only available on MacOS. Using this
option ensures that the main() method of the main Java class is executed on
the first thread of the process, i.e. the AppKit main UI thread.

This option is required when running applications that use the SWT library for
their user interface. This includes Eclipse and Eclipse Platform-based applications. It is also required for applicationst that use GWT.

This option is not required for applications that use AWT/Swing or JavaFX for
their UI, or for applications that do not have a graphical user interface.

Default Value:

-XstartOnFirstThread is off by default, i.e. the main() method may or may
not run on the first (AppKit) thread.

If -XstartOnFirstThread is not used with an SWT based application, such as
Eclipse, then the following warning will be printed:

***WARNING: Display must be created on main thread due to Cocoa restrictions.
Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
The application may still start but with limited or broken functionality.

Arguments Related to -XstartOnFirstThread:

TODO: link to -Xdock

Related Posts:

• Oracle article on bringing Java Applications to MacOS.

If you have additional comments, interesting experiences or even point of disagreement with this JVM argument description, please leave a comment. Your
insights will help the entire 10+ million java developer community to develop
one standard source of documentation for all the JVM arguments.

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvm-argument

  • xstartonfirstthread

  • startonfirstthread