问题
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.
https://www.mediafire.com/?vbckyjkr6di8dlk
回答1:
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:
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.
来源:https://stackoverflow.com/questions/28080220/lwjgl-jar-not-accesable