java能编译但是不能运行是什么原因呢

来源:百度知道 编辑:UC知道 时间:2024/05/15 19:15:46
Exception in thread "main" java.lang.NoClassDefFoundError: Example是这样提示的 小弟刚学java 我写的java源文件是Example.java

编译能通过代表语法没错。
引起该Exception的如果不是环境的问题,应该是你没在main函数所在的类的声明前加上public,如:

public class Example
{
}