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

  
 

(很抱歉,如果你希望能更加清楚地看清图片或是图上的文字的话,你可以按住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学习者应该不能陌生)
2. 在myEclipse 菜单->Windows->Proferences->java-> Installs  Jres重新设置JDK路径,改为开发程序时的JDK版本(如上图)(我做到这一步就可以了!我的eclipse是7.0,jdk是6u13的。)
3. Windows->Proferences->java->Compiler,将compiler compliance level设置为与上面相同的JDK(如上图,如果你今天2011年到官方下载的JDK那可能是1.6的了,建议勾选1.6)
-----------------------------------------------------------------------------
对于项目来说,有时候出现版本问题也是跟编译级别有关系,那修改一下就可以了(如下图)
解决这个问题可能需要感谢它,是它给了我灵感、:

@(报错)could not find the main class, Program will exit(已解决)的更多相关文章

  1. SpringBoot2整合Shiro报错 UnavailableSecurityManagerException: No SecurityManager accessible to the calling code 【已解决】

    SpringBoot集成Shiro报错 UnavailableSecurityManagerException: No SecurityManager accessible to the callin ...

  2. 【Python】pyinstaller打包运行报错failed to execute script main

    前言 最近用pyinstaller打包的时候一直报"failed to execute script main". 最终使用"pyinstaller --hidden-i ...

  3. 报错org.openqa.selenium.WebDriverException: disconnected: unable to connect to renderer解决方法

    做自动化时经常会遇到不兼容的问题,比如以下简单的脚本,主要是打开浏览器,然后最大化窗口,打开百度,输入内容搜索,代码如下: package com.gs.selenium; import org.op ...

  4. 搭建elsticsearch集群 报错with the same id but is a different node instance解决办法

    搭建elsticsearch集群 报错with the same id but is a different node instance解决办法 学习了:https://blog.csdn.net/q ...

  5. (转)启动网卡报错(Failed to start LSB: Bring up/down networking )解决办法总结

    启动网卡报错(Failed to start LSB: Bring up/down networking )解决办法总结 原文:http://blog.51cto.com/11863547/19059 ...

  6. MySQL8.0报错Can't connect to MySQL server on 'localhost' (10061)的解决办法

    MySQL8.0报错Can't connect to MySQL server on 'localhost' (10061)的解决办法 事情的起因     今天课堂上要展示小组项目,需要用一个软件叫W ...

  7. Java执行main方法,异常为:could not find the main class.program will exit

    未解决. Java执行方法,异常为:could not find the main class.program will exitmain 原文地址:http://rogerfederer.iteye ...

  8. spark-shell报错:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream

    环境: openSUSE42.2 hadoop2.6.0-cdh5.10.0 spark1.6.0-cdh5.10.0 按照网上的spark安装教程安装完之后,启动spark-shell,出现如下报错 ...

  9. 报错:Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/apache/hadoop/fs/FileSystem

    报错现象: Exception in thread "main" java.lang.NoClassDefFoundError: Lorg/apache/hadoop/fs/Fil ...

随机推荐

  1. JavaScript中的事件处理程序

    JavaScript和HTML之间的交互是通过事件实现的.事件,就是文档或者浏览器窗口中发生的一些特定的交互瞬间.可以使用事件处理程序来预订事件,以便在事件发生的时候执行响应的代码.这种观察者模式的模 ...

  2. C# 日期格式转换 string类型 20150329 转换为 2015/03/29

    DateTime.ParseExact("20150329", "yyyyMMdd", System.Globalization.CultureInfo.Cur ...

  3. Asp.Net MVC4.0 官方教程 入门指南之三--添加一个视图

    Asp.Net MVC4.0 官方教程 入门指南之三--添加一个视图 在本节中,您需要修改HelloWorldController类,从而使用视图模板文件,干净优雅的封装生成返回到客户端浏览器HTML ...

  4. Request.ServerVariables["Url"]

    Request.ServerVariables["Url"] 返回服务器地址 Request.ServerVariables["Path_Info"] 客户端提 ...

  5. JavaSE学习总结第11天_开发工具 & API常用对象1

      11.01 常见开发工具介绍 1:操作系统自带的记事本软件 2:高级记事本软件例:Editplus,Notepad++,UltraEdit 3:集成开发环境 IDE(Integrated Deve ...

  6. Oracle数据库的安装详解

    1.写在安装前的话 可能有很多的菜鸟十分害怕大型软件的安装,因为安装过程中的一些错误很让他们头疼.下面我就写一个教程,希望能对大家有帮助,在安装ORACLE之前给大家一点点的意见: (1)尽量要安装L ...

  7. Binary Tree Preorder Traversal and Binary Tree Postorder Traversal

    Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' valu ...

  8. php随笔9-thinkphp OA系统 集成UEditor

    版本信息:thinkphp 3.1.3 full     UEditor 1.4.3.1 utf8-php 1.将EUditor放在项目public目录下. 2.在指定页面加载编辑器 <!-- ...

  9. JavaScripts+jquery

    选择器 参数 element 一个用于搜索的元素.指向DOM节点的标签名. <div>div1</div> <div>div2</div> <sp ...

  10. STL front() ,back()和begin(),end()区别

    首先看看vector里面的: reference front(); const_reference front() const; queue里面的: value_type& front(); ...