起初你或许会认为是一个莫名其妙的错误,因为代码根本一点问题的都没有,可运行期间总是报这个错,比较郁闷。
出现Could not find the main class.program will exit和java.lang.UnsupportedClassVersionError 错误的原因,是因为我们使用高版本的JDK编译的Java class文件试图在较低版本的JVM上运行,所报的错误。“Could not find the main class. Program will exit.”
I just installed the latest available Eclipse version (3.2 milestone 5) and couldn’t run my ANT builds anymore. The error I got in the alert box was “Could not find the main class. Program will exit”根源分析:可能是在打开方式中的javaw版本过低。比如jdk1.5编译的class文件用1.4的javaw打开就会出现这个问题。解决方法1:控制面板->文件夹选项->文件类型->JAR下面的<高级>按纽
<操作>下面选open , 点右边的<编辑>,修改javaw路径,如:"C:\Program Files\Java\jdk1.5.0_10\bin\javaw.exe" -jar "%1" "%*"解决方法2:还有一种情况是:变量配的....(多了点...) 就两个就够用了(或者一个...) JAVA_HOME=D:\jdk1.6 
PATH=%JAVA_HOME%\bin; 应该ok了 
还有 你的 bin目录 一定要在 D:\jdk1.6 这个下面 
如果还有别的目录 那么 把它加上... e.g. D:\jdk1.6\XXXX解决方法3:在Eclipse窗口-->首选项-->Java-->编译器-->JDK一致性-->编辑器一致性级别,从5.0改到1.4就可以了。=======我最终是重装了MyEclipse,OK了========sun公司的观点CAUSE WJView.exe or Javaw.exe cannot find the program it is trying to run. 
SOLUTION If this error occurs during startup, it is mostly likely caused by a spyware or adware program which is missing, corrupt, or partially deleted. 
Remove Spyware/Adware Using your favorite search engine, search for "spyware removal utility" as your search phrase. This search will help you locate many free spyware removal utilities. Note: The Spyware Removal Utility can help you get rid of this error message partially. Any new spyware can get itself downloaded to your system later. To get rid of this problem completely, try the second option given below. 
Remove WJView entries from Startup Wjview lets you view Windows based Java applications. You might receive an error message if Wjview attempts to start an application on your system that no longer exists. You may need to modify the system configuration settings to completely get rid of the error. To do so, follow these steps: 
Click Start > Run. 
The Run dialog box appears. 
Type msconfig.exe. 
Click OK. 
The System Configuration Utility dialog box appears. 
Select the Startup tab. 
Deselect the WJView.exe and/or javaw.exe check boxes that are associated with this problem. 
Click OK. 
You will be prompted to restart the computer. Restart the system to apply changes.