Exception in thread "main" java.lang.Noclass DefFoundError问题
来源:百度知道 编辑:UC知道 时间:2024/05/10 09:26:54
写了个简单的java程序 编译成功了 可是运行时就出现Exception in thread "main" java.lang.Noclass DefFoundError类名 其他程序运行时都成功了的 不会是环境变量没有设置好吧 哪位帮帮我啊
程序为:
import java.awt.*;
import java.awt.event.*;
class ButtonColor extends WindowAdapter implements ActionListener{
Frame f; Button b; Button c; Button d; int flag=0;
public static void main(String args[]){
ButtonColor e=new ButtonColor();
e.init();
}
public void init(){
f=new Frame("基本GUI编程");
f.setLayout(new FlowLayout());
f.addWindowListener(this);
b=new Button("红色");
b.addActionListener(this);
f.add(b);
c=new Button("蓝色");
c.addActionListener(this);
f.add(c);
d=new Button("黄色");
d.addActionListener(this);
f.add(d);
f.setVisible(true);
f.setSize(300,300);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b)
程序为:
import java.awt.*;
import java.awt.event.*;
class ButtonColor extends WindowAdapter implements ActionListener{
Frame f; Button b; Button c; Button d; int flag=0;
public static void main(String args[]){
ButtonColor e=new ButtonColor();
e.init();
}
public void init(){
f=new Frame("基本GUI编程");
f.setLayout(new FlowLayout());
f.addWindowListener(this);
b=new Button("红色");
b.addActionListener(this);
f.add(b);
c=new Button("蓝色");
c.addActionListener(this);
f.add(c);
d=new Button("黄色");
d.addActionListener(this);
f.add(d);
f.setVisible(true);
f.setSize(300,300);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==b)
你缺少了main函数,程序的入口没了还怎么执行啊。。。
快加个 public static void main(String []arg)
{......}吧
修正:
看到Main()函数了。。。抱歉一开始没看见。。
1.是不是你为你的类定义了包啊,如果是的话运行是需要带上包名,比如:
package mypackage;
public class MyClass{
//...
}
要这样运行:
java mypackage.MyClass
2.是否环境变量没设置好??
如没的话,设置好classpath即可
set classpath=(.class文件所在目录)
如:
set classpath=c:\jdk\myclass
再java MyClass(注意大小写,与.java文件中的类名相同)
Exception EOleSysError in module
英语作文,主题:in th park
Realistic novel in the 18th century
on June 5th和in June
Christmas in the 13th Month
nothing in thé world 是什么意思?
Report ranks China 6th in overall strength 怎么翻译?
谁能告诉我feminism in 17th century 在英国
The film was released on 11th July in China
Fashions in America before the 19th century_____those of Egland.