import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class JFrame1 implements ActionListener{
public JFrame1(){
JFrame f=new JFrame("JFrameDemo");
Container contentPane=f.getContentPane();
JButton b=new JButton("Click me to get new Window");
b.addActionListener(this);
contentPane.add(b);
f.pack();
f.setVisible(true);
f.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent e){
JFrame newf=new JFrame();
newf.setSize(200,200);
newf.setVisible(true);
}
public static void main(String[] args){
new JFrame1();
}
}
程序很好的编译通过,但是运行时,出现Exception in thread "main" java.lang.NoClassDefFoundError;JFrame1/class
请问这是怎么回事,环境我也配置好了,但每次运行JAVA程序时都会出现这种情况,我没有配置错啊,它能编译怎么会配置错了呢,没理由啊。
import java.awt.event.*;
import javax.swing.*;public class JFrame1 implements ActionListener{
public JFrame1(){
JFrame f=new JFrame("JFrameDemo");
Container contentPane=f.getContentPane();
JButton b=new JButton("Click me to get new Window");
b.addActionListener(this);
contentPane.add(b);
f.pack();
f.setVisible(true);
f.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent e){
JFrame newf=new JFrame();
newf.setSize(200,200);
newf.setVisible(true);
}
public static void main(String[] args){
new JFrame1();
}
}
程序很好的编译通过,但是运行时,出现Exception in thread "main" java.lang.NoClassDefFoundError;JFrame1/class
请问这是怎么回事,环境我也配置好了,但每次运行JAVA程序时都会出现这种情况,我没有配置错啊,它能编译怎么会配置错了呢,没理由啊。
值为 C:\Program Files\Java\jdk1.6.0_04
b>在原变量 path 中
增加 ;%JAVA_HOME%\bin
c>增加变量 CLASSPATH
增加值
.;$JAVA_HOME/lib/tools.jar;$JAVA_HOME/lib/dt.jar;%JAVA_HOME%\lib d:\>java bbb (bbb 类名)