Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT does not work on Mac M1(I have the ARM64 swt jar file, and I do -XstartOnMainThread but nothing happens)
SWT does not work on Mac M1 [message #1861208] Fri, 29 September 2023 06:59
Jacob Bubbleface is currently offline Jacob BubblefaceFriend
Messages: 1
Registered: September 2023
Junior Member
Hey there,


My JDK is OpenJDK 11

I am using a Mac M1 (ARM64) so I got the corresponding swt JAR file for my program.

When i run my code, it does not open the display.

This is my code

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class Main {
    public static void main(String[] args) {
        Display display = Display.getDefault();
        Shell shell = new Shell(display);
        shell.setText("Hello World");
        shell.setSize(500, 500);
        shell.open();
        shell.layout();
        shell.forceActive();
    }
}


and whether I run it in my IDE or via the command:

java -XstartOnFirstThread -classpath /Users/nugget1/git/testswt/out/production/testswt:/Users/nugget1/swt.jar Main


It does not open the display.

When I remove the -XstartOnFirstThread option and run the command, I get a stack trace error which says that I need it

it says:

***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread
Exception in thread "main" org.eclipse.swt.SWTException: Invalid thread access
        at org.eclipse.swt.SWT.error(SWT.java:4893)
        at org.eclipse.swt.SWT.error(SWT.java:4808)
        at org.eclipse.swt.SWT.error(SWT.java:4779)
        at org.eclipse.swt.widgets.Display.error(Display.java:1100)
        at org.eclipse.swt.widgets.Display.createDisplay(Display.java:851)
        at org.eclipse.swt.widgets.Display.create(Display.java:835)
        at org.eclipse.swt.graphics.Device.<init>(Device.java:130)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:734)
        at org.eclipse.swt.widgets.Display.<init>(Display.java:725)
        at org.eclipse.swt.widgets.Display.getDefault(Display.java:1434)
        at Main.main(Main.java:6)



Any help would be much appreciated...

Thanks
Previous Topic:GLCanvas: "Unsupported color depth" on VmWare Linux
Next Topic:Strange behavior on menus using Sonoma
Goto Forum:
  


Current Time: Thu May 02 12:41:54 GMT 2024

Powered by FUDForum. Page generated in 0.03123 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top