Hello Guest

Help Please

  • 7 Replies
  • 12372 Views
Help Please
« on: December 26, 2015, 19:54:27 »
I am on a macbook air using eclipse, and I follow the exact instructions from many videos to get this error. I am running the example code off the main website.

Hello LWJGL 3.0.0b SNAPSHOT!
Exception in thread "main" java.lang.ExceptionInInitializerError
   at org.lwjgl.glfw.GLFW.glfwCreateWindow(GLFW.java:1248)
   at learningshit.HelloWorld.init(HelloWorld.java:55)
   at learningshit.HelloWorld.run(HelloWorld.java:24)
   at learningshit.HelloWorld.main(HelloWorld.java:111)
Caused by: java.lang.IllegalStateException: GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is initialized before GLFW.
   at org.lwjgl.glfw.EventLoop$OffScreen.<clinit>(EventLoop.java:39)
   ... 4 more

Can anyone help me?

*

Offline Cornix

  • *****
  • 488
Re: Help Please
« Reply #1 on: December 26, 2015, 20:13:11 »
Quote
GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is initialized before GLFW.

Re: Help Please
« Reply #2 on: December 26, 2015, 21:24:22 »
Quote
GLFW windows may only be created on the main thread and that thread must be the first thread in the process. Please run the JVM with -XstartOnFirstThread. For offscreen rendering, make sure another window toolkit (e.g. AWT or JavaFX) is initialized before GLFW.

What does that mean, how do I fix this?

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: Help Please
« Reply #3 on: December 26, 2015, 21:51:25 »
Quote
Please run the JVM with -XstartOnFirstThread.

You need to stick "-XstartOnFirstThread" as a runtime argument for Java. If you go into the properties of your Eclipse project there should be some kind of "runtime" options one of which should be something along the lines of "command line arguments." Put that there.

Re: Help Please
« Reply #4 on: December 26, 2015, 22:32:09 »
Quote
Please run the JVM with -XstartOnFirstThread.

You need to stick "-XstartOnFirstThread" as a runtime argument for Java. If you go into the properties of your Eclipse project there should be some kind of "runtime" options one of which should be something along the lines of "command line arguments." Put that there.

Thank you!
Went to Run -> Run Configuration -> Clicked on my project ->Arguements Tab -> VM Arguements -> Pasted -XstartOnFirstThread -> Clicked apply, and then run, and it worked!!!!!

Re: Help Please
« Reply #5 on: June 22, 2017, 08:57:14 »
some error.

Exception in thread "Thread-0" java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalStateException: GLFW windows may only be created on the main thread.
   at org.lwjgl.glfw.EventLoop$OffScreen.<clinit>(EventLoop.java:37)
   ... 4 more

okay, it's works in main thread.

but what we do if client-server application engineering, and server part use main thread, and GUI needed in second thread for local run of app, or just use in main for app with implements Runnable (runnable make another thread) ????

is this a hard/soft restriction or bug? with what is connected? can i work around it?
« Last Edit: June 22, 2017, 09:04:57 by yoojeen »

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Help Please
« Reply #6 on: June 22, 2017, 09:08:00 »
This is a macOS limitation and it is per process. If you need multiple event loops for some reason, then you'd have to launch your application multiple times and use an IPC mechanism to talk to each other.

Re: Help Please
« Reply #7 on: June 22, 2017, 11:50:20 »
yep, i use MacOS.

i want launch application multiple times, but communication with each other is not needed (tcp/udp only if its a game), it must be separate instances, just needed a graphics in a Runnable class
« Last Edit: June 22, 2017, 11:56:36 by yoojeen »