Help Please

Started by bluevideogame, December 26, 2015, 19:54:27

Previous topic - Next topic

bluevideogame

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?

Cornix

QuoteGLFW 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.

bluevideogame

Quote from: Cornix on December 26, 2015, 20:13:11
QuoteGLFW 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?

quew8

QuotePlease 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.

bluevideogame

Quote from: quew8 on December 26, 2015, 21:51:25
QuotePlease 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!!!!!

yoojeen

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?

spasi

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.

yoojeen

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