import java.awt.*;
import java.awt.event.*;
public class ChatFrame extends WindowAdapter implements ActionListener
{
Frame f;
Button b1;
TextArea ta;
TextField tf;
public ChatFrame()
{
f = new Frame("聊天窗口");
f.setSize(400,300);
ta = new TextArea();
f.add(ta);
Panel p = new Panel();
f.add(p,"South");
tf = new TextField(20);
b1 = new Button("Send");
p.add(tf);
p.add(b1);
b1.addActionListener(this);
f.setVisible(true);
f.addWindowListener(this);
}
public void actionPerformed(ActionEvent e)
{
ta.append(tf.getText()+"\n");
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public static void main(String args[])
{
new ChatFrame();
}
}
这是一个聊天窗口的设计,编译已经通过,,但是在运行的时候,出现了这样的错误,
java.lang.NoClassDefFoundError: ChatFrame/class
Exception in thread "main"
请问大虾们,这是怎么回事哟....我运行其他此类代码的时候,也有这样的问题,
是不是配置出了问题?
import java.awt.event.*;
public class ChatFrame extends WindowAdapter implements ActionListener
{
Frame f;
Button b1;
TextArea ta;
TextField tf;
public ChatFrame()
{
f = new Frame("聊天窗口");
f.setSize(400,300);
ta = new TextArea();
f.add(ta);
Panel p = new Panel();
f.add(p,"South");
tf = new TextField(20);
b1 = new Button("Send");
p.add(tf);
p.add(b1);
b1.addActionListener(this);
f.setVisible(true);
f.addWindowListener(this);
}
public void actionPerformed(ActionEvent e)
{
ta.append(tf.getText()+"\n");
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
public static void main(String args[])
{
new ChatFrame();
}
}
这是一个聊天窗口的设计,编译已经通过,,但是在运行的时候,出现了这样的错误,
java.lang.NoClassDefFoundError: ChatFrame/class
Exception in thread "main"
请问大虾们,这是怎么回事哟....我运行其他此类代码的时候,也有这样的问题,
是不是配置出了问题?
环境变量是classpath上加上 ".;"
这是我的classpath的路径名
(我在机器上面安装了Tomcat)