Mac M1 Error GLFW Main Thread

I had a few questions/difficulties regarding using a mac to develop in jme.
Running produces a resulting error “IllegalStateException: GLFW may only be used on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.”

To solve this I attempted the following:

  1. calling “Configuration.GLFW_CHECK_THREAD0.set(false);” prior to app.start() in the main function, which produced an error “uncaught exception ‘NSInternalInconsistencyException’, reason: 'NSWindow drag regions should only be invalidated on the Main Thread”
  2. I searched online and another big solution and one that is also in the original error itself is to add a JVM option “-XstartOnFirstThread”. I had some difficulty in locating it in the launched sdk though and i could only find the following:

    however, I got no change in behavior for posting in properties and and error for posting in the second one, and neither appears to be quite the same as program properties/vm args that i see in some other imgs/screenshots from people. So maybe I’m just not finding it? If so could you let me know where to find it?
    I just downloaded the latest netbeans/jmonkey sdks today if versions are relevant.
1 Like

So the SDK works right? But any project you make with it doesn’t?

-XstartOnFirstThread should be the correct answer. I think the first one newer really was reported working. But now everything just depends then that what kind of project did you make? What build system you chose for the project? Ant or Gradle?

Also, if nothing else works… you can revert back to using LWJGL 2. It works on Macs.

Yeah I am able to startup a project properly and it builds w/out problems, but crashes when running.
I am using Gradle, and was wondering if maybe the screenshotted region was the wrong place to be adding args in since I never used netbeans/jmonkey sdk before (usually use intellij).
When I add it into the Arguments portion of that screenshot as “-XstartOnFirstThread” I get an error that includes “Unknown command line option ‘-X’.” so I feel like I must be doing something wrong.

For reverting to LWJGL 2 would that have any effect on the code I would write or would that mostly just affect the internal parts of the engine (so ex if I later get a windows/somehow get it working I could basically just move the project to LWJGL 3).

It should not have. If it has, you are doing something wrong. LWJGL is jMEs problem, not yours. It is not a dependency of your project. You should not pay attention to it in your code. Otherwise you hardcode yourself to certain version (implementation of jME). Well, of course we have the package jME-lwjgl and you need to include one of those in your project, but that is it.

With Gradle projects all arguments go to build.gradle file. Like so:

application {
     applicationDefaultJvmArgs = ["-XstartOnFirstThread"]
1 Like

I tried using LWJGL 2 and it runs fine, but I did get a warning:
" initOpenAL
WARNING: Pausing audio device not supported. initOpenAL
WARNING: OpenAL EFX not available! Audio effects won’t work.
I was wondering if these are significant or not in your opinion (since audio seems important but im not sure why its not working, is there something else i should install for OpenAL), or if you had any ideas of how to fix you.
Other than this I had the window with the square appear fine.

EDIT: Additional output information if its useful that preceded it.
INFO: Audio Renderer Information

  • Device: MacBook Pro Speakers
  • Vendor: Apple Computer Inc.
  • Renderer: Software
  • Version: 1.1
  • Supported channels: 64

Adding the argument to the gradle file did result in LWJGL 3 running but I never saw an output window/screen in my computer.

The println was reached and outputted so it did begin running successfully but for some reason I never saw a window and there was no java app icon that appeared on the lower bar.

This is just fine probably. I would imagine you can still have audio. Just some extensions wont work.

You probably should work towards LWJGL 3. As that is the future. But if you are just trying to settle in to jME… forget that battle. Just don’t reference any stuff from LWJGL and you should be ok later to try to get LWJGL 3 working without any code changes. And this should not be a challenge for anyone.

Also stay away from Swing/AWT. This is pre-cursor to LWJGL 3 on Macs…

1 Like

Thank you for all your help!


When using IntelliJ IDEA,

  1. open Edit Run Configuration dialog

Right Click → More Run/Debug → Modify Run Configurations…

  1. Add vm options
  • Modify options → Add VM Options → Add VM options
  • add -XstartOnFirstThread to VM Options, but NOT Program arguments.
  • store as project file, so you don’t need to change configuraions every time.

  1. Update JDK

If you do everything above but still can’t run your app, make sure you don’t use any Swing/AWT thing in your code.
If it’s still not working, update jdk to 11+. It is the AWTLoader in DesktopAssetManager stopped the main thread. Update JDK will fix it.

Sorry if I was being confusing but I’m not using IntelliJ im using netbeans + SDK. Thank you for making such an organized response though

One thing that came to my mind… the default SDK Gradle project adds the following dependency org.jmonkeyengine:jme3-awt-dialogs. Take that out (build.gradle), and with the

application {
     applicationDefaultJvmArgs = ["-XstartOnFirstThread"]

it might just work with LWJGL 3 then.

Removing the said dependency you lose the graphic settings selection that by default pops up when you start a jME project.

As a side note, we’ll add these improvements to the SDK itself so that in the future a Mac user just might get a working LWJGL 3 app out of the box.

Edit: also I’m not sure did you figure it out, but changing between LWJGL versions is just a matter of changing the LWJGL-jme dependency between org.jmonkeyengine:jme3-lwjgl3 and org.jmonkeyengine:jme3-lwjgl


I made the changes and now it works perfectly w/ LWJGL3. Thank you for your help!


I also have M1. Where did you set Configuration.GLFW_CHECK_THREAD0.set(false);? I’m not sure which package I’m supposed to import Configuration from?

I was running into the “GLFW may only be used on the main thread [… ]Please run the JVM with -XstartOnFirstThread.” which seems to have been solved by

application {
     applicationDefaultJvmArgs = ["-XstartOnFirstThread"]

inside build.gradle.

Now my error is

GLFW may only be used on the main thread. This check may be disabled with Configuration.GLFW_CHECK_THREAD0.

hence my question.

(Or perhaps I’m in a code smell and should reacrchitect lol.)

Details: JME v 3.6.1, lwjgl v3.3.2, IBM JDK v20.0.2, macOS 14.2.1.

Configuration comes from the org.lwjgl.system package.

Any invocation of Configuration methods should occur before LWJGL is initialized, for instance in main().