简体   繁体   English

LWJGL项目java.lang.NoClassDefFoundError

[英]LWJGL project java.lang.NoClassDefFoundError

I'm working on a project using LWJGL and I can't seem to get my jar to run. 我正在使用LWJGL进行项目,但似乎无法运行jar。 It runs fine inside my IDE (netbeans), but the jar itself gives me the error. 它在我的IDE(netbeans)中运行良好,但是jar本身给了我错误。

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.lwjgl.opengl.Display

I've tried a lot of things to fix this error. 我已经尝试了很多方法来修复此错误。 I think it has something to do with the LWJGL natives not being correctly linked. 我认为这与LWJGL本机未正确链接有关。

I've linked the natives in netbeans by putting this in the VM options. 通过将其放在VM选项中,我已经在netbeans中链接了本机。

-Djava.library.path="C:\Users\Lemonzap\Desktop\Projects\Game Programming\LWJGL -3\native\windows\x64"

The path is the path to where my 64 bit windows LWJGL natives are kept. 该路径是我的64位Windows LWJGL本机保留到的路径。

I've also tried adding this line to the beggining of main. 我还尝试过将这行添加到main的开头。

System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath());

I have a feeling that I need to change this line a bit though since there isn't a natives folder in my lib folder. 我有一种感觉,尽管我的lib文件夹中没有natives文件夹,但我还是需要更改这一行。 I've spent a few days researching this issue and trying out other people's solutions with no luck. 我花了几天时间研究这个问题,并尝试了其他人的解决方案,但没有运气。 I would greatly appreciate some help with this problem. 对于这个问题,我将不胜感激。

Your natives need to be inside your jar. 您的本地人需要放在罐子里。 I had a lot of issues with this when I tried to deploy my LWJGL project. 当我尝试部署我的LWJGL项目时,我对此有很多问题。

I used Jarsplice to do it. 我用Jarsplice来做。 It takes the IDE-built jar, adds the libraries and natives, and exports to a .jar , .exe , .app , or .sh . 它采用IDE构建的jar,添加库和本机,然后导出到.jar.exe.app.sh

On my Linux system, I had this error because the system library libXxf86vm.so.1 was missing. 在我的Linux系统上,出现此错误是因为缺少系统库libXxf86vm.so.1 This means that a missing external library is also able to produce this error. 这意味着丢失的外部库也能够产生此错误。 On your windows, you probably need an extra dll. 在您的Windows上,您可能需要一个额外的dll。

These command solved in for me (on Ubuntu trusty): 这些命令为我解决了(在Ubuntu上可信赖):

sudo apt-get install libxxf86vm1 fglrx

Btw: it's also possible that java/jni/lwjgl have problems with pathnames containing spaces... 顺便说一句:java / jni / lwjgl也可能在包含空格的路径名方面有问题...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM