Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 一个很棘手的Java程序。。。
sxjy





发贴: 17
积分: 0
于 2004-11-30 22:23 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我调试了一个关于线程的程序,编译的时候没错,但是运行的时候出了以下的问题,请问是什么原因?

java.lang.NoClassDefFoundError: Counter1 (wrong name: c14/Counter1)
  at java.lang.ClassLoader.defineClass0(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Exception in thread "main" Exit code: 1
There were errors

该程序的源程序是:

package c14;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class Counter1 extends Applet {
private int count = 0;
private Button
onOff = new Button("Toggle"),
start = new Button("Start");
private TextField t = new TextField(10);
private boolean runFlag = true;
public void init() {
add( t);
start.addActionListener(new StartL());
add(start);
onOff.addActionListener(new OnOffL());
add(onOff);
}
public void go() {
while (true) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e){}
if(runFlag)
t.setText(Integer.toString(count++));
}
}
class StartL implements ActionListener {
public void actionPerformed(ActionEvent e) {
go();
}
}
class OnOffL implements ActionListener {
public void actionPerformed(ActionEvent e) {
runFlag = !runFlag;
}
}
public static void main(String[] args) {
Counter1 applet = new Counter1();
Frame aFrame = new Frame("Counter1");
aFrame.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
aFrame.add(applet, BorderLayout.CENTER);
aFrame.setSize(300,200);
applet.init();
applet.start();
aFrame.setVisible(true);
}
}


sxjy edited on 2004-11-30 22:25


话题树型展开
人气 标题 作者 字数 发贴时间
12218 一个很棘手的Java程序。。。 sxjy 2483 2004-11-30 22:23

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923