请高手帮看看以下错误通常是如何造成的...
Exception in thread "main" java.lang.NoClassDefFoundError: bounce (wrong name: B
ounce)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

解决方案 »

  1.   

    NoClassDefFoundError类没有放到classpath下面或者类没有放到相应的package文件夹下面Bounce 这个类贴出来 然后说说你的目录结构 你在什么路径下 怎么运行的详细说说就知道
      

  2.   

    classpath:E:\donesoft\jdk1.5\lib;E:\donesoft\jdk1.5\jre\bin;path:
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Gemplus\GemSafe Libraries\BIN;E:\donesoft\jdk1.5\bin;E:\donesoft\jdk1.5\jre\bin;E:\donesoft\jdk1.5\lib;代码上不来,被我这边的内网限制了...引入以下包:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;
      

  3.   

    代码是java核心技术上的一个多线程例子.
      

  4.   

    .;E:\donesoft\jdk1.5\lib;E:\donesoft\jdk1.5\jre\bin;改成上面的还有你的运行的入口类是什么 包结构 是什么 贴几个import 没有用的
      

  5.   

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.*;
    import javax.swing.*;/**
    Shows an animated bouncing ball.
    */
    public class Bounce
    {
    public static void main(String[] args)
    {
    JFrame frame = new BounceFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.show();
    }
    }/**
    The frame with canvas and buttons.
    */
    class BounceFrame extends JFrame
    {
    /**
    Constructs the frame with the canvas for showing the
    bouncing ball and Start and Close buttons
    */
    public BounceFrame()
    {
    setSize(WIDTH, HEIGHT);
    setTitle("Bounce");Container contentPane = getContentPane();
    canvas = new BallCanvas();
    contentPane.add(canvas, BorderLayout.CENTER);
    JPanel buttonPanel = new JPanel();
    addButton(buttonPanel, "Start",
    new ActionListener()
    {
    public void actionPerformed(ActionEvent evt)
    {
    addBall();
    }
    });
      

  6.   

    addButton(buttonPanel, "Close",
    new ActionListener()
    {
    public void actionPerformed(ActionEvent evt)
    {
    System.exit(0);
    }
    });
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    }/**
    Adds a button to a container.
    @param c the container
    @param title the button title
    @param listener the action listener for the button
    */
    public void addButton(Container c, String title,
    ActionListener listener)
    {
    JButton button = new JButton(title);
    c.add(button);
    button.addActionListener(listener);
    }/**
    Adds a bouncing ball to the canvas and makes
    it bounce 1,000 times.
    */
    public void addBall()
    {
    try
    {
    Ball b = new Ball(canvas);
    canvas.add(b);for (int i = 1; i <= 1000; i++)
    {
    b.move();
    Thread.sleep(5);
    }
    }
    catch (InterruptedException exception)
    {
    }
    }
      

  7.   

    private BallCanvas canvas;
    public static final int WIDTH = 450;
    public static final int HEIGHT = 350;
    }/**
    The canvas that draws the balls.
    */
    class BallCanvas extends JPanel
    {
    /**
    Add a ball to the canvas.
    @param b the ball to add
    */
    public void add(Ball b)
    {
    balls.add(b);
    }public void paintComponent(Graphics g)
    {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    for (int i = 0; i < balls.size(); i++)
    {
    Ball b = (Ball)balls.get(i);
    b.draw(g2);
    }
    }private ArrayList balls = new ArrayList();
    }/**
    A ball that moves and bounces off the edges of a
    component
    */
    class Ball
    {
    /**
    Constructs a ball in the upper left corner
    @c the component in which the ball bounces
    */
    public Ball(Component c) { canvas = c; }/**
    Draws the ball at its current position
    @param g2 the graphics context
    */