[英]java.lang.NoClassDefFoundError with LWJGL
So, I am afraid that I have to join the crowds flocking here and asking: "What's wrong with my code?" 因此,恐怕我不得不和一群人涌向这里,问:“我的代码有什么问题?”
I've recently started coding in Java and I've had none of this error until I tried using lwjgl in a project. 我最近开始用Java进行编码,直到尝试在项目中使用lwjgl之前,我都没有遇到此错误。 So, the question is: What is wrong with my JAR when I get the following: 所以,问题是:当我得到以下信息时,我的JAR有什么问题:
java -cp \lib\win32\lwjgl.jar -jar Valor.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/opengl/Display
at bin.Disp.createWindow(Disp.java:18)
at bin.Thread.gameLoop(Thread.java:13)
at Main.main(Main.java:4)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.opengl.Display
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
As is, I am extremely confused about this. 照原样,我对此感到非常困惑。 I've gone through seven or eight posts here about this very problem, and another five or six on other web sites, yet none of the methods those people used seem to work for me. 我在这里浏览了七到八篇有关此问题的文章,在其他网站上浏览了另外五六篇文章,但是这些人使用的方法似乎都不适合我。
Currently, my file structure is: 目前,我的文件结构是:
Valor
-Valor.jar
lib
win32
-lwjgl.jar
-lwjgl.dll
Manifest: 表现:
Manifest-Version: 1.0
Main-Class: Main
I did try defining a classpath here... Didn't work. 我确实尝试在这里定义类路径...没有用。 So, I'm pretty much as confused as I can possibly get. 因此,我尽可能地感到困惑。 Thank you for your help. 谢谢您的帮助。
Edit: This error doesn't occur while running in Eclipse, only when I export and try to run it myself. 编辑:仅当我导出并尝试自己运行它时,才在Eclipse中运行时不会发生此错误。
Try to run it like this: 尝试像这样运行它:
java -cp lib\win32\lwjgl.jar;Valor.jar Main
The problem is that the -cp
option is ignored when -jar
is used. 问题是使用-jar
时-cp
选项将被忽略。
Alternativelly you could extend the class path by adding a Class-Path:
entry in your manifest and puting lib\\win32\\lwjgl.jar
in it. 或者,您可以通过在清单中添加Class-Path:
条目并将lib\\win32\\lwjgl.jar
放入其中来扩展类路径。
Class-Path: lib\win32\lwjgl.jar
By running java -cp \\lib\\win32\\lwjgl.jar -jar Valor.jar
you're telling Java to look for LWJGL classpath near the root of your filesystem. 通过运行java -cp \\lib\\win32\\lwjgl.jar -jar Valor.jar
您告诉Java在文件系统根目录附近查找LWJGL类路径。 Seeing your directory structure, use: 查看目录结构,使用:
java -cp .\lib\win32\lwjgl.jar -jar Valor.jar
Notice the .
请注意.
at the beginning. 一开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.