java - Error: Main method not found -
error: main method not found in class essence.game, please define main method as: public static void main(string[] args)
the code:
package essence; import static org.lwjgl.opengl.gl11.*; import java.util.list; import java.util.arraylist; import java.util.random; import org.lwjgl.input.*; import org.lwjgl.opengl.*; import org.lwjgl.*; public class game{ list<box> shapes = new arraylist<box>(16); public game(){ try { display.setdisplaymode(new displaymode(800,600)); display.settitle("essence"); display.create(); } catch (lwjglexception e){ e.printstacktrace(); } shapes.add(new box(15, 15)); shapes.add(new box(100, 150)); glmatrixmode(gl_projection); glloadidentity(); glortho(0, 800, 600, 0, 1, -1); glmatrixmode(gl_modelview); while(!display.iscloserequested()){ glclear(gl_color_buffer_bit); if(keyboard.iskeydown(keyboard.key_escape)){ display.destroy(); system.exit(0); } (box box : shapes) { box.draw(); } display.update(); display.sync(60); } display.destroy(); } private static class box { public boolean selected = false; public int x, y; private float colorred, colorblue, colorgreen; box (int x, int y){ this.x = x; this.y = y; random randomgenerator = new random(); colorred = randomgenerator.nextfloat(); colorblue = randomgenerator.nextfloat(); colorgreen = randomgenerator.nextfloat(); } boolean inbounds(int mousex, int mousey){ if(mousex > x && mousex < x + 50 && mousey > y && mousey < y + 50) return true; else return false; } void randomizecolors(){ random randomgenerator = new random(); colorred = randomgenerator.nextfloat(); colorblue = randomgenerator.nextfloat(); colorgreen = randomgenerator.nextfloat(); } void update(int dx, int dy){ x += dx; y += dy; } void draw(){ glcolor3f(colorred, colorgreen, colorblue); glbegin(gl_quads); glvertex2f(x, y); glvertex2f(x + 50, y); glvertex2f(x + 50, y + 50); glvertex2f(x, y + 50); glend(); } } public static void main(string[] args) { new game(); } }
now let's change to:
package essence; public class game{ public static void main(string[] args) { } }
it still give same error. checked folder layout, confirmed eclipse\data\workspace\essence\src\essence
, eclipse\data\workspace\essence\bin\essence
it cannot java installation, because other projects work fine. here's screenshot of project within eclipse:
http://gyazo.com/296d53b33fa2619ca300c8a896d097dc
what cause of error , way fix it?
it happens me well. restarting compiler fix problem. example, if running eclipse, restart eclipse.
Comments
Post a Comment