简体   繁体   English

Java applet NoClassDefFound错误

[英]Java applet NoClassDefFound error

I have an applet which is directly in my html page. 我有一个直接在我的html页面中的applet。 It uses 4 other files. 它使用4个其他文件。 I am getting a NoClassDefFound error. 我收到NoClassDefFound错误。 My html file is in the same directory as my .class files, and looks like this: 我的html文件与我的.class文件位于同一目录中,如下所示:

<html>
<body>
<h1>Here is my Asteroids game!</h1>
<applet codebase = "." code = "Asteroids.class" name = "Asteroids" width = "640" height = "480" hspace = "0" vspace = "0" align = "middle">
</applet>
</body>
</html>

I'm using internet explorer, and my other applets work fine. 我正在使用Internet Explorer,我的其他小程序工作正常。 Do I need to include the other files in my <applet> tag? 我是否需要在<applet>标记中包含其他文件?

Full error: 完整错误:

Java Plug-in 10.6.2.24
Using JRE version 1.7.0_06-b24 Java HotSpot(TM) Client VM
User home directory = C:\Users\Stafford
----------------------------------------------------
c:   clear console window
f:   finalize objects on finalization queue
g:   garbage collect
h:   display this help message
l:   dump classloader list
m:   print memory usage
o:   trigger logging
q:   hide console
r:   reload policy configuration
s:   dump system and deployment properties
t:   dump thread list
v:   dump thread stack
x:   clear classloader cache
0-5: set trace level to <n>

Stack trace: 堆栈跟踪:

asteroids:(wrong name asteroids/Asteroids)

A quick search of the error and I came across someone else with a similar issue and an answer. 快速搜索错误,我遇到了一个有类似问题和答案的其他人。 Try the suggestion over there: Java applet Error ... What is wrong? 尝试那边的建议: Java applet错误......有什么问题?

I should mention that it is probably best to package your application into a jar file as it starts to grow in the number of class files. 我应该提一下,最好将应用程序打包到一个jar文件中,因为它开始增加类文件的数量。 In that case, if javascript is acceptable, you may want to look into using one of the deployment libraries such as DeployJava.js or the newer dtjava.js for JavaFX applets. 在这种情况下,如果javascript是可接受的,您可能希望使用其中一个部署库(如DeployJava.js)或更新的dtjava.js来使用JavaFX applet。 (still works for regular applets iirc) (仍适用于常规小程序iirc)

You'll also need to go this route if you plan on utilizing any restricted features that require a signed applet. 如果您计划使用任何需要签名小程序的受限制功能,您还需要使用此路线。 (such as file i/o) (例如文件i / o)

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

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