Could not find the main class Program will exit 解决方案
起初你或许会认为是一个莫名其妙的错误,因为代码根本一点问题的都没有,可运行期间总是报这个错,比较郁闷。
出现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了========[color=#008000][/color]
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.
------解决方案--------------------晕死 还以为要帮你解决问题了!不过既然来了就需要留下脚印!住楼主在以后的日子里事业成功吧!
------解决方案--------------------哦 谢谢共享
------解决方案--------------------我还不会eclipse,不过在命令行下也出现类似的问题,是因为安装了oracle的缘故