java程序运行出错

来源:百度知道 编辑:UC知道 时间:2024/05/11 01:03:20
我刚刚开始学java,按照书本上的将程序输入编译成功,生成class文件可是运行时出现exception in thread "main" java.lang.NoClassDefFoundError
could not find the main class.
A JNI error has occurred,please check your installation这是哪里出错了,我已经将java版本升到最新,而且重装了好几遍,可还是出错。请高手们帮忙看一下
public class Hello
{
public static void main(String[ ] args)
{
System.out.println("Hello,World!");
}
}

呵呵
那个第一句的意思是说你的程序出现异常,
后面说检测不到你安装,一种原因是你的环境变量配置有误:
path
文件路径\bin 例如在C盘下的jdk中 c:\jdk\bin
classpath
,:文件路径\lib ,:c\jdk\lib
另是你的文件位置不对-没放到J2SE中,或者是文件名不是Hello.java

把程序贴上来
书上的也不一定对

exception in thread "main" java.lang.NoClassDefFoundError
could not find the main class.
就是找不到main方法的意思
你写了main方法没有?
任何程序都有程序入口点
而这里main方法就是程序入口点