吃榴莲的小黄人
2015-03-24 13:55
采纳率: 0%
浏览 1.9k
已采纳

java.lang.NoClassDefFoundError 不是环境变量

原码
import java.awt.*;
import java.awt.event.*;

public class TankClient extends Frame {
int x = 50, y = 50;
@Override
public void paint(Graphics g) {
Color c = g.getColor();
g.setColor(Color.RED);
g.fillOval(50, 50, 30, 30);
y += 5;
}

public void lauchFrame() {
    this.setLocation(400, 300);
    this.setSize(800, 600);
    this.setTitle("TankWar");
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    this.setResizable(false);
    this.setBackground(Color.GREEN);
    setVisible(true);

    new Thread(new PaintThread()).start();
}

public static void main(String[] args) {
    TankClient tc = new TankClient();
    tc.lauchFrame();
}
private class PaintThread implements Runnable{

    @Override
    public void run() {
        repaint();
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }}

}
问题
Exception in thread "main" java.lang.NoClassDefFoundError: TankClient$PaintThread
at TankClient.lauchFrame(TankClient.java:27)
at TankClient.main(TankClient.java:32)
Caused by: java.lang.ClassNotFoundException: TankClient$PaintThread
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 2 more

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题