Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
来源:互联网 发布:英伦 知乎 编辑:程序博客网 时间:2024/04/26 12:04
Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
起初你或许会认为是一个莫名其妙的错误,因为代码根本一点问题的都没有,可运行期间总是报这个错,比较郁闷。
出现Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 错误的原因,是因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行,所报的错误。
因为,高版本的JDK生成的class文件使用的格式,可能与低版本的JDK的.class文件格式不同。这样,低版本的JVM无法解释执行这个.class文件,会抛出Could not find the main class.program will exit,java.lang.UnsupportedClassVersionError不支持的Class版本错误。
这个错误尤其在JDK5与JDK5之前的版本上表现明显。因为,JDK5在Java语法上作了不少增强,引入了一些新的.class文件的元素,导致旧版本的JVM无法解释、执行.class文件。即使这个类并没有使用任何JDK5的新元素,但是JDK5生成的.class文件,JDK1.4及其以前的JVM都无法辨认!
在MyEclipse-->应用服务器下,指定Tomcat5。指定Tomcat使用jdk1.4。这样,就全部指定使用Jdk1.4来编译和运行程序了。如果全部指定jdk5也是可以的。但是,绝对不能够使用jdk5编译程序,而又在jdk1.4上运行程序,那样将会抛出java.lang.UnsupportedClassVersionError不支持的Class版本错误。
这种情况下,不论是Eclipse生成的war包,还是ant文件生成war包,都使用jdk5编译,就会在运行时出现错误,该应用程序将无法启动。如果你查看Tomcat的日志文件,将会看到正是java.lang.UnsupportedClassVersionError错误发生了!
其实无非就是版本问题,JDK版本的问题。
解决方法:在Eclipse窗口-->首选项-->Java-->编译器-->JDK一致性-->编辑器一致性级别,从5.0改到1.4就可以了。
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法 .
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法 .
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- 报错could not find the main class:java.overWrite.overWrite.Program will exit.的解决方法
- 【解决方法】Could not find the main class Program will exit
- Java中Could not find the main class.program will的解决方法(转)
- Java中Could not find the main class.program will的解决方法
- Java中Could not find the main class.program will
- 安装java的时候出现Could not find the main class.program will exit
- Java执行main方法,异常为:could not find the main class.program will exit
- could not find the main class. program will exit问题的解决方法
- android实现程序的后台运行
- Avoiding Full GCs in HBase with MemStore-Local Allocation Buffers: Part 2
- Android UI设计准则
- 《java 多线程中的死锁》
- page_clientValidate也分组
- Java中Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 的解决方法
- [ios开发ios5新特性之]如何在iOS5中定制用户界面
- Avoiding Full GCs in HBase with MemStore-Local Allocation Buffers: Part 3
- shell遍历文件下所有文件
- 函数——>oracle详细
- Java读书笔记01
- 调试心得
- 浅析iPhone平台三种应用类型的布局方式
- 创业者如何才能少犯错