This should be a pretty simple question. I am trying to us LWJGL and I watched a tutoiral on how to get started but the import statements and all lwjgl code is getting error messages. The file is below. What am I doing wrong? I added the jar in properties but it is still not working.
-
You added the jar in the what now? – Elliott Frisch Jan 22 '15 at 02:10
-
In properties of the project, I clicked java build path and then add jars and added the lwjgl.jar file. – Sam Kirkiles Jan 22 '15 at 02:11
-
I don't you added the correct jar file then... maybe it's source? Look at the contents with `jar tvvf` (or use winzip) and see if it contains class files (and isn't corrupt). – Elliott Frisch Jan 22 '15 at 02:22
-
Yes everything is there just checked. Did you see the project I linked? – Sam Kirkiles Jan 22 '15 at 02:36
-
I posted an answer, assuming you use eclipse. – DripDrop Jan 22 '15 at 03:32
2 Answers
You need to add the natives to the path. To do this (Under eclipse), expand the LWJGL jar, and under the 'natives' item, add the natives directory that fits your OS (Windows for windows, Linux for Linux, etc.) This adds all the required LWJGL system files so your game could use the engine properly. The natives folders should be in the root folder 'natives', and should contain the operating system name in the path name. Please note that 1: the folders should be in the game directory, or wherever they where when you added them, and 2: you need to compile the game with each natives folder to be able to run the game on that OS.

- 994
- 1
- 9
- 18
LWJGL uses its own variables for the path to the native libraries (If they are not found you will get a "no LWJGL in path"-error):
System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());
If you kept the file structure from the LWJGL package you can use something like this:
switch(LWJGLUtil.getPlatform())
{
case LWJGLUtil.PLATFORM_WINDOWS:
{
JGLLib = new File("./native/windows/");
}
break;
case LWJGLUtil.PLATFORM_LINUX:
{
JGLLib = new File("./native/linux/");
}
break;
case LWJGLUtil.PLATFORM_MACOSX:
{
JGLLib = new File("./native/macosx/");
}
break;
}
System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());

- 2,844
- 1
- 25
- 41