---
title: "Java执行main方法，异常为:could not find the main class.program will exit"
author: "413899327"
date: "2010-08-14T16:12:11Z"
tags: []
categories: ["编程语言"]
slug: "java-main-could-not-find-the-main-class-program-will-exit"
draft: false
lastmod: "2010-12-11T23:20:52Z"
id: 737377
url: "https://rogerfederer.iteye.com/blog/737377"
---

could not find the main class.program will exit!



原因和解决办法如下：
出现这个错误是由于你的jdk版本与eclipse高版本配置造成的.
因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行，所报的错误。   因为，高版本的JDK生成的class文件使用的格式，可能与低版本的JDK的.class文件格式不同。这样，低版本的JVM无法解释执行这个.class文件，会抛出Could not find the main class.program will exit不支持的Class版本错误。


解决方法：
1. 弄清楚该程序是在哪个JDK版本下开发的 
2. 在myEclipse 菜单->Windows->Proferences->java-> Installs  Jres重新设置JDK路径，改为开发程序时的JDK版本（我做到这一步就可以了！我的eclipse是7.0，jdk是6u13的。）
3. Windows->Proferences->java->Compiler，将compiler compliance level设置为与上面相同的JDK