Search code examples
javaeclipselwjgl

Java(TM) Platform SE binary is not responding


every time i try running my java project through eclipse (I use the lwjgl lib so i create a window) the window appears , freezes , then it's not responding it's not a code problem i tried a very basic code like

package data;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

import static org.lwjgl.opengl.GL11.*;
public class Boot {
    public Boot()
    {

        Display.setTitle("A.T's game");
        try {
            Display.setDisplayMode(new DisplayMode (640, 480));
            Display.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
        }
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0,640,480,0,1,-1);
        glMatrixMode(GL_MODELVIEW);

        while(!Display.isCloseRequested())
        {
            glBegin(GL_LINES);
            glVertex2f(35,35);
            glVertex2f(53,53);
            glEnd();
        }
        Display.destroy();
    }
    public static void main(String[] args)
    {
        new Boot() ;
    }

}

Solution

  • Your while loop is an infinite loop. You have to call Display.update() or it will not respond to any input, including the close request.

    while (!Display.isCloseRequested()) {
        //...
        Display.update();
    }