简体   繁体   English

Java LWJGL小程序NoClassDefFound

[英]Java lwjgl applet noclassdeffound

I'm trying to use my java applet on a html document but It just keeps giving the same errors over and over again. 我试图在html文档上使用我的java applet,但是它总是不断地给出相同的错误。 I'm using eclipse. 我正在使用日食。 When i debug/run the applet it all works fine, but when I export it to a jar file and try to use it with a html document it gives this error: 当我调试/运行applet时,一切正常,但是当我将其导出到jar文件并尝试与html文档一起使用时,出现此错误:

java.lang.NoClassDefFoundError: org/newdawn/slick/opengl/Texture

Here is my java code: http://pastebin.com/B3R6nj1a 这是我的Java代码: http : //pastebin.com/B3R6nj1a

This is what the .jar file contains: 这是.jar文件包含的内容:

-lib
  -jars
    lwjgl.jar
    lwjgl_util.jar
    slick-util.jar
  -natives-win
    *all the dlls*

-META-INF
  -*files*

-res
  grass.png
  wood.png

.classpath
.project
Camera.class
Main$1.class
Main$2.class
Main.class

I do have everything right in the build path from my project. 我确实在我的项目的构建路径中拥有一切。 (So added the three external jars. And added native-win to lwjgl.jar) (因此添加了三个外部jar。并且向lwjgl.jar添加了native-win)

This is my html code: 这是我的html代码:

<html>
<head>
</head>
<body>
   <applet archive='3dtest.jar' Code='Main' width = "640" height = "480"></applet>
</body>
</html>

I've also tried to change "Code='Main' " to "Code='Main.class'" also didn't work. 我也尝试将“ Code ='Main'”更改为“ Code ='Main.class'”也不起作用。

Does anybody has any idea why I'm getting the error? 有人知道我为什么要出错吗? Thanks in advance. 提前致谢。

-Tim -Tim

EDIT: .classpath file: http://pastebin.com/i7y4XYaf 编辑:.classpath文件: http ://pastebin.com/i7y4XYaf

This is what the .jar file contains: 这是.jar文件包含的内容:

 -lib -jars lwjgl.jar ... 

Those Jars should not be there. 那些罐子不应该在那里。 They should be separate Jars on the site referenced something like this: 它们应该是站点上引用类似以下内容的单独Jars:

<html>
<head>
</head>
<body>
<applet 
  archive='3dtest.jar,lwjgl.jar,lwjgl_util.jar,slick-util.jar,all_dlls.jar..' 
  code='Main' 
  width="640" 
  height="480">
</applet>
</body>
</html>

That is presuming the HTML is in the same directory as all the Jars. 假定HTML与所有Jars位于同一目录中。

You need to post relevant code, not everything and hope someone will pick through it all. 您需要发布相关代码,而不是所有内容,并希望有人能仔细阅读所有内容。

java.lang.NoClassDefFoundError: org/newdawn/slick/opengl/Texture means that class is not present in your classpath. java.lang.NoClassDefFoundError: org/newdawn/slick/opengl/Texture表示您的类路径中没有该类。

You need to make sure your applet is packaged properly when deploying it. 您需要确保在部署小程序时正确打包了该小程序。 See http://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html 参见http://docs.oracle.com/javase/tutorial/deployment/applet/deployingApplet.html

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

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