gpt4 book ai didi

java.lang.NoSuchMethodError : getPointer

转载 作者:行者123 更新时间:2023-12-02 05:43:51 24 4
gpt4 key购买 nike

我在 IDE 中运行一个程序,但是在 IDE 中运行它自己的 jar 文件,一旦我将其导出为可运行的 jar 文件(并使其成为一个 fat jar,添加库和 native 等),它给出以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: getPointer
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:65)
at org.lwjgl.Sys.loadLibrary(Sys.java:81)
at org.lwjgl.Sys.<clinit>(Sys.java:98)
at org.lwjgl.opengl.Display.<clinit>(Display.java:128)
at Joehot200.TerrainDemo.setUpDisplay(TerrainDemo.java:1956)
at Joehot200.TerrainDemo.startGame(TerrainDemo.java:2029)
at Joehot200.Main.main(Main.java:55)

我设置的显示方法是:

private static void setUpDisplay() {
try {
DisplayMode displayMode = null;
DisplayMode[] modes = Display.getAvailableDisplayModes(); //this is line 1956

for (int i = 0; i < modes.length; i++)
{
if (modes[i].isFullscreenCapable())
{
displayMode = modes[i];
}
}
if (displayMode == null){
displayMode = new DisplayMode(100, 100);
}
//Display.setDisplayMode(new DisplayMode(WINDOW_DIMENSIONS[0], WINDOW_DIMENSIONS[1]));
Display.setDisplayMode(displayMode);
Display.setResizable(true);
Display.setTitle("Pirate game");
//Display.setFullscreen(true);
Display.create();

} catch (LWJGLException e) {
e.printStackTrace();
cleanUp(true);
}
}

如何修复这个愚蠢的错误并使其正常工作?

最佳答案

您很可能缺少 native 库。您可以像这样设置这些路径:

System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());

参见Here

如果您使用 LWJGL 附带的文件夹结构,您将必须选择正确的 native ,如下所示:

        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());

最后:您正在使用 Slick2D,因此这可能会引起兴趣( Source ):

I looked over the error and figured it must be related to one of the files being older than another, and then I realized that I was using the lwjgl jar that came with slick. I replaced it with the one from the website, and it fixed my problem.

关于java.lang.NoSuchMethodError : getPointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24283770/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com