LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: Help Please  (Read 2983 times)

bluevideogame

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
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?
Logged

Cornix

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 447
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.
Logged

bluevideogame

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
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?
Logged

quew8

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 562
  • 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.
Logged

bluevideogame

  • Newbie
  • *
  • Offline Offline
  • Posts: 3
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!!!!!
Logged

yoojeen

  • Newbie
  • *
  • Offline Offline
  • Posts: 7
Re: Help Please
« Reply #5 on: Today at 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?
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Online Online
  • Posts: 1805
Re: Help Please
« Reply #6 on: Today at 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.
Logged

yoojeen

  • Newbie
  • *
  • Offline Offline
  • Posts: 7
Re: Help Please
« Reply #7 on: Today at 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
Logged