当前位置: 技术问答>java相关
java的问题
来源: 互联网 发布时间:2015-03-04
本文导语: 下面的程序: public class Greeting { public void greet() { System.out.println("hi"); } } 编译通过 可是运行出错: java.lang.NoClassDefFoundError: Greeting Exception in thread "main" Exit code: 1 There were errors 怎...
下面的程序:
public class Greeting {
public void greet() {
System.out.println("hi");
}
}
编译通过
可是运行出错:
java.lang.NoClassDefFoundError: Greeting
Exception in thread "main" Exit code: 1
There were errors
怎么解决错误
谢谢
public class Greeting {
public void greet() {
System.out.println("hi");
}
}
编译通过
可是运行出错:
java.lang.NoClassDefFoundError: Greeting
Exception in thread "main" Exit code: 1
There were errors
怎么解决错误
谢谢
|
没有程序入口(public static void main(String[] args)).
每一个可执行的java 类必须有它且只能有一个。可以修改为:
public class Greeting {
public void greet() {
System.out.println("hi");
}
public static void main(String[] args){
Greeting g=new Greeting();
g.greet();
}
}
每一个可执行的java 类必须有它且只能有一个。可以修改为:
public class Greeting {
public void greet() {
System.out.println("hi");
}
public static void main(String[] args){
Greeting g=new Greeting();
g.greet();
}
}