• could not find the main class, Program will exit java编译器版本的问题


    could not find the main class, Program will exit 

     
     
    (很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以按住ctrl不动,然后向上滚动鼠标的滚轮。要改变回来同理向下滚动即可、)

    --------------------------------------------------------------------

    今天2011.4.20:
    这篇文章是我刚接触myeclipse的时候写的,一年过去了,感觉自己成熟了点,这篇文章还是有点不足,所以补上了。
    -------------------------------------------------
    一段在jcreator中能正常运行的代码,在myeclipse中
    老是出现could not find the main class,program will exit。
    这足可以说明代码没错,是程序的问题了。
    原因和解决办法如下:
    因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行,所报的错误。   因为,高版本的JDK生成的class文件使用的格式,可能与低版本的JDK的.class文件格式不同。这样,低版本的JVM无法解释执行这个.class文件,会抛出Could not find the main class.program will exit不支持的Class版本错误。 这个错误尤其在JDK5与JDK5之前的版本上表现明显。因为,JDK5在Java语法上作了不少增强,引入了一些新的.class文件的元素,导致旧版本的JVM无法解释、执行.class文件。即使这个类并没有使用任何JDK5的新元素,但是JDK5生成的.class文件,JDK1.4及其以前的JVM都无法辨认。
    解决方法:
    1. 弄清楚该程序是在哪个JDK版本下开发的 (JDK对于java学习者应该不能陌生)
    (报错)could not find the main class, Program will exit(已解决) - Jn - Judas.n
    2. 在myEclipse 菜单->Windows->Proferences->java-> Installs  Jres重新设置JDK路径,改为开发程序时的JDK版本(如上图)(我做到这一步就可以了!我的eclipse是7.0,jdk是6u13的。)
    (报错)could not find the main class, Program will exit(已解决) - Jn - Judas.n
     
    3. Windows->Proferences->java->Compiler,将compiler compliance level设置为与上面相同的JDK(如上图,如果你今天2011年到官方下载的JDK那可能是1.6的了,建议勾选1.6)
    -----------------------------------------------------------------------------
    对于项目来说,有时候出现版本问题也是跟编译级别有关系,那修改一下就可以了(如下图)
    (报错)could not find the main class, Program will exit(已解决) - Jn - Judas.n
     
    (报错)could not find the main class, Program will exit(已解决) - Jn - Judas.n
     
  • 相关阅读:
    Python return语句用法分析
    set built-in function
    dict built-in function
    String bulit-in function
    tuple built-in function
    Pyhton:List build-in function
    Python之如果添加扩展包
    关于编辑器
    attachEvent和addEventListener详解
    jquery异步调用页面后台方法
  • 原文地址:https://www.cnblogs.com/anuoruibo/p/2432156.html
Copyright © 2020-2023  润新知