问题描述
我使用Eclipse IDE创建了一个applet程序。现在即时创建.html文件如下:
I have created an applet program using Eclipse IDE. Now im creating .html file as below:
<html>
<APPLET CODE="Chase.class" width=500 height=400>
</APPLET>
</html>
当我执行此文件时,我得到的错误是:
When Im executing this file the error im getting is:
java.lang.NoClassDefFoundError: Chase (wrong name: pong/Chase)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
在Eclipse IDE中创建了新项目并将程序打包到pong文件夹中。
In Eclipse IDE is have created new project and packaged the program into "pong" folder.
任何人都可以解释为什么会出现此错误环?
Can anybody explain why this error is occuring?
编辑:
添加一些Chase.java代码行,以便澄清。这是一个简单的小程序:
Adding few Chase.java code lines, for clarification. It is simple applet:
package pong;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class Chase extends Applet implements Runnable
{ ... }
推荐答案
类路径中没有类名 Chase
。
错误的名称
指定包含指定包的类名可能有误。
wrong name
specifies there might be mistake with class name with package specified.
如果您的类声明 package
例如
package a;
public class MyApplet extends Applet{}
然后在HTML中给出 a.MyApplet
then in HTML give a.MyApplet
更新
似乎是
< APPLET CODE =pong.Chase.classwidth = 500 height = 400>
dir结构也应该
- - - - -
|
|-your html file
|-pong folder
|
|- Chases.class
如果包名称 pong
这篇关于错误:java.lang.NoClassDefFoundError:Chase(错误名称:pong / Chase)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!