Need help with LWJGL/JOGL

I downloaded source code from http://www.cokeandcode.com/spaceinvaders104/spaceinvaders104.zip .
When I try to build it in IntelliJ Idea, i get few errors ;p


Information:Note: Some input files use unchecked or unsafe operations.
Information:Compilation completed with 88 errors and 1 warning
Information:88 errors
Information:1 warning
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\jogl\JoglGameWindow.java
    Error:Error:line (8)package net.java.games.jogl does not exist
    Error:Error:line (9)package net.java.games.jogl does not exist
    Error:Error:line (10)package net.java.games.jogl does not exist
    Error:Error:line (11)package net.java.games.jogl does not exist
    Error:Error:line (12)package net.java.games.jogl does not exist
    Error:Error:line (13)package net.java.games.jogl does not exist
    Error:Error:line (14)package net.java.games.jogl does not exist
    Error:Error:line (27)cannot find symbol class GLEventListener
    Error:Error:line (37)cannot find symbol class GLCanvas
    Error:Error:line (39)cannot find symbol class GL
    Error:Error:line (70)cannot find symbol class GL
    Error:Error:line (160)cannot find symbol class GLDrawable
    Error:Error:line (188)cannot find symbol class GLDrawable
    Error:Error:line (217)cannot find symbol class GLDrawable
    Error:Error:line (237)cannot find symbol class GLDrawable
    Error:Error:line (99)cannot find symbol class GLCapabilities
    Error:Error:line (99)cannot find symbol variable GLDrawableFactory
    Error:Error:line (106)cannot find symbol class Animator
    Warning:Warning:line (114)[deprecation] show() in java.awt.Window has been deprecated
    Error:Error:line (165)cannot find symbol variable GL
    Error:Error:line (172)cannot find symbol variable GL
    Error:Error:line (193)cannot find symbol variable GL
    Error:Error:line (194)cannot find symbol variable GL
    Error:Error:line (223)cannot find symbol variable GL
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\jogl\TextureLoader.java
    Error:Error:line (23)package net.java.games.jogl does not exist
    Error:Error:line (41)cannot find symbol class GL
    Error:Error:line (52)cannot find symbol class GL
    Error:Error:line (97)cannot find symbol variable GL
    Error:Error:line (98)cannot find symbol variable GL
    Error:Error:line (99)cannot find symbol variable GL
    Error:Error:line (100)cannot find symbol variable GL
    Error:Error:line (139)cannot find symbol variable GL
    Error:Error:line (141)cannot find symbol variable GL
    Error:Error:line (147)cannot find symbol variable GL
    Error:Error:line (149)cannot find symbol variable GL
    Error:Error:line (150)cannot find symbol variable GL
    Error:Error:line (161)cannot find symbol variable GL
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\jogl\Texture.java
    Error:Error:line (3)package net.java.games.jogl does not exist
    Error:Error:line (51)cannot find symbol class GL
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\lwjgl\TextureLoader.java
    Error:Error:line (24)package org.lwjgl.opengl does not exist
    Error:Error:line (78)cannot find symbol variable GL11
    Error:Error:line (97)cannot find symbol variable GL11
    Error:Error:line (98)cannot find symbol variable GL11
    Error:Error:line (99)cannot find symbol variable GL11
    Error:Error:line (100)cannot find symbol variable GL11
    Error:Error:line (132)cannot find symbol variable GL11
    Error:Error:line (139)cannot find symbol variable GL11
    Error:Error:line (141)cannot find symbol variable GL11
    Error:Error:line (147)cannot find symbol variable GL11
    Error:Error:line (149)cannot find symbol variable GL11
    Error:Error:line (150)cannot find symbol variable GL11
    Error:Error:line (161)cannot find symbol variable GL11
    Error:Error:line (154)cannot find symbol variable GL11
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\lwjgl\Texture.java
    Error:Error:line (3)package org.lwjgl.opengl does not exist
    Error:Error:line (53)cannot find symbol variable GL11
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\lwjgl\LWJGLGameWindow.java
    Error:Error:line (5)package org.lwjgl does not exist
    Error:Error:line (6)package org.lwjgl does not exist
    Error:Error:line (7)package org.lwjgl.input does not exist
    Error:Error:line (8)package org.lwjgl.input does not exist
    Error:Error:line (9)package org.lwjgl.opengl does not exist
    Error:Error:line (10)package org.lwjgl.opengl does not exist
    Error:Error:line (69)cannot find symbol variable Window
    Error:Error:line (70)cannot find symbol variable Window
    Error:Error:line (91)cannot find symbol variable Display
    Error:Error:line (91)cannot find symbol variable Window
    Error:Error:line (94)cannot find symbol variable Mouse
    Error:Error:line (97)cannot find symbol variable GL11
    Error:Error:line (100)cannot find symbol variable GL11
    Error:Error:line (102)cannot find symbol variable GL11
    Error:Error:line (103)cannot find symbol variable GL11
    Error:Error:line (105)cannot find symbol variable GL11
    Error:Error:line (112)cannot find symbol class LWJGLException
    Error:Error:line (141)cannot find symbol variable Keyboard
    Error:Error:line (144)cannot find symbol variable Keyboard
    Error:Error:line (147)cannot find symbol variable Keyboard
    Error:Error:line (151)package org.lwjgl.input does not exist
    Error:Error:line (161)cannot find symbol variable GL11
    Error:Error:line (162)cannot find symbol variable GL11
    Error:Error:line (163)cannot find symbol variable GL11
    Error:Error:line (171)cannot find symbol variable Window
    Error:Error:line (173)cannot find symbol variable Window
    Error:Error:line (173)cannot find symbol variable Keyboard
    Error:Error:line (175)cannot find symbol variable Window
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\SystemTimer.java
    Error:Error:line (3)package com.dnsalias.java.timer does not exist
    Error:Error:line (15)cannot find symbol class AdvancedTimer
    Error:Error:line (22)cannot find symbol variable AdvancedTimer
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\jogl\JoglSprite.java
    Error:Error:line (5)package net.java.games.jogl does not exist
    Error:Error:line (72)cannot find symbol class GL
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\lwjgl\LWJGLSprite.java
    Error:Error:line (5)package org.lwjgl.opengl does not exist

I use the included JDK (Idea 4155).
Any ideas?

You need to add the required libraries (JOGL etc.) to the project’s classpath (File > Settings > Modules > Libraries > Add Jar/Directory).

Still doesn’t work… I copied whole LWJGL directory to game source dir, and i got even more errors… ???

I haven’t used those libraries, but using them should be like any other library:

  1. Download lwjgl-1.0beta2.zip from http://lwjgl.org/download.php
  2. Copy the lwjgl.jar file from that ZIP file to a safe place (for example to a directory “lib” in the same place where you keep the project’s other files).
  3. Add lwjgl.jar to the classpath in the project’s settings.

You might also want to get a ZIP with LWJGL’s source codes, which you then can link to the JAR file in the classpath configuration page. This will give you quick access to the source and javadocs of the LWJGL library from within the IDE.

That should fix the error messages about the org.lwjgl package and its subpackages not existing. Then do the same things for the other libraries which you need (apparently JOGL and the com.dnsalias.java.timer package, unless it comes with JOGL).

The simplest way to get all required libraries is to copy the same JARs which are used in running the program. Just see what JARs http://www.cokeandcode.com/spaceinvaders104/si104.jnlp uses and copy them manually from WebStart’s cache (~\Application Data\Sun\Java\Deployment\cache\javaws).

Thanks for your help. I don’t have problems with libraries any more, but i get some other messages…


Information:100 errors
Information:9 warnings
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\opengl\MacOSXDisplay.java
    Error:Error:line (255)cannot find symbol method glGetInteger(int,java.nio.IntBuffer)
    Error:Error:line (256)non-static method glViewport(int,int,int,int) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\test\opengl\PbufferTest.java
    Error:Error:line (192)non-static method glClear(int) cannot be referenced from a static context
    Error:Error:line (195)non-static method glPushMatrix() cannot be referenced from a static context
    Error:Error:line (197)non-static method glTranslatef(float,float,float) cannot be referenced from a static context
    Error:Error:line (198)non-static method glRotatef(float,float,float,float) cannot be referenced from a static context
   ...
    Error:Error:line (228)non-static method glLoadIdentity() cannot be referenced from a static context
    Error:Error:line (230)non-static method glOrtho(double,double,double,double,double,double) cannot be referenced from a static context
    Error:Error:line (416)non-static method glClear(int) cannot be referenced from a static context
    Error:Error:line (417)non-static method glMatrixMode(int) cannot be referenced from a static context
    Error:Error:line (418)non-static method glLoadIdentity() cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\examples\spaceinvaders\Sprite.java
    Error:Error:line (99)non-static method glPushMatrix() cannot be referenced from a static context
    Error:Error:line (105)non-static method glTranslatef(float,float,float) cannot be referenced from a static context
    Error:Error:line (108)non-static method glBegin(int) cannot be referenced from a static context
    Error:Error:line (110)non-static method glTexCoord2f(float,float) cannot be referenced from a static context
    Error:Error:line (111)non-static method glVertex2f(float,float) cannot be referenced from a static context
    Error:Error:line (113)non-static method glTexCoord2f(float,float) cannot be referenced from a static context
    Error:Error:line (114)non-static method glVertex2f(float,float) cannot be referenced from a static context
    Error:Error:line (116)non-static method glTexCoord2f(float,float) cannot be referenced from a static context
    Error:Error:line (117)non-static method glVertex2f(float,float) cannot be referenced from a static context
    Error:Error:line (119)non-static method glTexCoord2f(float,float) cannot be referenced from a static context
    Error:Error:line (120)non-static method glVertex2f(float,float) cannot be referenced from a static context
    Error:Error:line (122)non-static method glEnd() cannot be referenced from a static context
    Error:Error:line (125)non-static method glPopMatrix() cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\examples\spaceinvaders\TextureLoader.java
    Error:Error:line (111)glGenTextures(int,java.nio.IntBuffer) in org.lwjgl.opengl.GL11 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (164)non-static method glBindTexture(int,int) cannot be referenced from a static context
    Error:Error:line (180)non-static method glTexParameteri(int,int,int) cannot be referenced from a static context
    Error:Error:line (181)non-static method glTexParameteri(int,int,int) cannot be referenced from a static context
    Error:Error:line (185)non-static method glTexImage2D(int,int,int,int,int,int,int,int,java.nio.Buffer) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\examples\spaceinvaders\SoundManager.java
    Error:Error:line (89)non-static method alSourcei(int,int,int) cannot be referenced from a static context
    Error:Error:line (90)non-static method alSourcePlay(int) cannot be referenced from a static context
    Error:Error:line (100)non-static method alSourcei(int,int,int) cannot be referenced from a static context
    Error:Error:line (101)non-static method alSourcePlay(int) cannot be referenced from a static context
    Error:Error:line (110)alGetSourcei(int,int,int) in org.lwjgl.openal.AL10 cannot be applied to (int,int)
    Error:Error:line (124)alGenSources(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (129)non-static method alGetError() cannot be referenced from a static context
    Error:Error:line (150)alGenBuffers(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (157)alBufferData(int,int,java.nio.Buffer,int,int) in org.lwjgl.openal.AL10 cannot be applied to (int,int,java.nio.ByteBuffer,int)
    Error:Error:line (175)alSourceStop(int) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (178)alDeleteSources(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (183)alDeleteBuffers(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\examples\spaceinvaders\Texture.java
    Error:Error:line (92)non-static method glBindTexture(int,int) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\opengl\glu\Util.java
    Error:Error:line (242)cannot find symbol method glGetInteger(int,java.nio.IntBuffer)
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\test\opengl\shaders\Shader.java
    Error:Error:line (97)non-static method glGetError() cannot be referenced from a static context
    Error:Error:line (121)non-static method glGetString(int) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\test\openal\BasicTest.java
    Error:Error:line (115)non-static method alGetString(int) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\java\org\lwjgl\test\openal\PlayTestMemory.java
    Error:Error:line (75)non-static method alIsExtensionPresent(java.lang.String) cannot be referenced from a static context
    Error:Error:line (93)alGenBuffers(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (94)non-static method alGetError() cannot be referenced from a static context
    Error:Error:line (99)alGenSources(int,java.nio.IntBuffer) in org.lwjgl.openal.AL10 cannot be applied to (java.nio.IntBuffer)
    Error:Error:line (100)non-static method alGetError() cannot be referenced from a static context
    Error:Error:line (116)alBufferData(int,int,java.nio.Buffer,int,int) in org.lwjgl.openal.AL10 cannot be applied to (int,int,java.nio.ByteBuffer,int)
    Error:Error:line (123)alBufferData(int,int,java.nio.Buffer,int,int) in org.lwjgl.openal.AL10 cannot be applied to (int,int,java.nio.ByteBuffer,int)
    Error:Error:line (130)non-static method alGetError() cannot be referenced from a static context
    Error:Error:line (136)non-static method alSourcei(int,int,int) cannot be referenced from a static context
C:\Documents and Settings\MG\Desktop\spaceinvaders104\spaceinvaders104\org\newdawn\spaceinvaders\jogl\JoglGameWindow.java

You’re loading LWJGL code with JOGL libs.

LWJGL:
GL.glWhatever();
glWhatever(); // using static import

JOGL:
GL gl = …;
gl.glWhatever();