Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: java.lang.NoClassDefFoundError: Chase (wrong name: pong/Chase)

Tags:

java

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)

In Eclipse IDE is have created new project and packaged the program into "pong" folder.

Can anybody explain why this error is occuring?

Edit:

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
{ ...  }
like image 363
Gaurav Navgire Avatar asked Jan 24 '11 09:01

Gaurav Navgire


1 Answers

There is no class name Chase in your classpath.

wrong name specifies there might be mistake with class name with package specified.

if your class declares package for example

package a;
public class MyApplet extends Applet{}

then in HTML give a.MyApplet

Update

in your case it seems

<APPLET CODE="pong.Chase.class" width=500 height=400>

also dir structure should be

- - - - -
      |
      |-your html file
      |-pong folder
          |
          |- Chases.class

will do if package name is pong

like image 79
jmj Avatar answered Nov 25 '22 17:11

jmj