@(报错)could not find the main class, Program will exit(已解决)

简介: 原文 @(报错)could not find the main class, Program will exit(已解决)      (很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以按住ctrl不动,然后向上滚动鼠标的滚轮。

原文 @(报错)could not find the main class, Program will exit(已解决)

 
(报错)could not find the main class, Program will exit(已解决) - jn - Judas.n

(很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以按住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
解决这个问题可能需要感谢它,是它给了我灵感、:
目录
相关文章
|
Java Maven Spring
|
9天前
|
Linux
报错 Package ‘oniguruma‘, required by ‘virtual:world‘, not found
报错 Package ‘oniguruma‘, required by ‘virtual:world‘, not found
7 0
|
6月前
|
前端开发
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
【前端异常】Module build failed: Error: ENOENT: no such file or directory, scandir ‘G:\OPWeb\public\node_m
68 0
|
8月前
|
Java
Java Error: The public type HelloWorld must be defined in its own file
Java Error: The public type HelloWorld must be defined in its own file
94 0
|
Linux
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
编译OpenJDK8:error: control reaches end of non-void function [-Werror=return-type]
148 0
|
Java
2022-07-15 17:47:32.079 ERROR 10280 --- [ main] o.s.b.d.LoggingFailureAnalys错误解决方法
2022-07-15 17:47:32.079 ERROR 10280 --- [ main] o.s.b.d.LoggingFailureAnalys错误解决方法
341 0
|
Java jenkins 测试技术
Maven问题-Unable to find main class
Maven问题-Unable to find main class
831 0
How to find unit test class by code
Created by Wang, Jerry, last modified on Dec 20, 2014
101 0
How to find unit test class by code