不知道 大家有遇到过 Could not find main class 的情况 如例图1
明明 是一个很简单的类 却 执行不了
没有写 main 函数的 同志 请 自行填上
这里就不 教怎么 填加 main 主函数了-_-!
继续
说下原因
是因为我们使用高版本的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就可以了
也可以如 例图2
- 描述: 例图1
- 大小: 57.9 KB
- 大小: 28.2 KB
- 大小: 16.4 KB
分享到:
相关推荐
在Myeclipse 8.5中用外带的tomcat时候,会因为JDK版本的问题出现Could not find the main class,按照上述文档的步骤就可以解决,我亲自体验过
Eclipse 编译时遇到错误could not find the main class,program will exit的解决方法
NULL 博文链接:https://yintech.iteye.com/blog/374842
解决 Can not find the main class. Program will exit. 难题
WIN7下运行Jar文件提示Could not find the main class
【SpringBoot】Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster报错明细问题解决后记 报错明细 IDEA SpringBoot集成hadoop运行环境,,本地启动项目,GET请求接口触发...
burp suite1.7.26破解版无时间限制 ,用于web安全性测试。 web中间人攻击 xss sql 注入 csrf 等常见漏洞 渗透测试必备
java反编译工具jd-gui, 1.4.0版本, 使用方式: 打开的文件应该为类似jar包文件,而不是单独的Class文件
抛出无法找到主类:org.apache.axis.wsdl.WSDL2Java(Throws Could not find main class: org.apache.axis.wsdl.WSDL2Java)。 添加本文的jar包压缩包解压出来的所有jar包到当前使用的java.exe 命令的lib目录下的ext...
java反编译工具jd-gui-1.4.0.jar 可以查看jar包中的.class文件的java代码
- FIX Remaks panel focusing on main form (via PostMessage), since TreeInspector in FlexEditSE captures focus on self. - FIX Invalid arc size calculation when flex-control's size changes via DocRect ...
解决Could not find the main class, Program will exit的错误的方法
<mainClass>com.csii.pe.channel.stream.context.IoCContainerStart</mainClass> <!-- 是否指定项目classpath下的依赖 --> <addClasspath>true <!-- 指定依赖的时候声明前缀 --> <classpathPrefix>./lib/ ...
androidandroidpublic class first_Java { /** * @param args */ public static void main(String[] args) { ...則Could not find the main class: first_Java. Program will exit. 因為檔名要一樣才行
的错误 <br>如果没有使用其他插件啊,类库等,以上的步骤就可以了 但如果用了,例如我用了SWT,就麻烦一点了 如果不作以下操作,会出现 Could not find the main class, Program will exit. 的错误。...
sqoop框架开发工具使用的jar,目前版本有1.4.6和1.4.7两个jar包,启动Sqoop时,抛出异常:Error: Could not find or load main class .usr.local.sqoop-1.4.7.sqoop-1.4.7.jar 则可以下载资源将sqoop-1.4.7.jar放到...
解决错误:Could not find or load main class org.apache.sqoop.Sqoop。把这个sqoop-1.4.7.jar放到sqoop根目录下的lib目录中,即可。 如果你没有积分,也可以自己去这个地址下载:...
包括meEclipse下如何制作jar文件 制作exe文件 JavaLanuncher reshacker,manifes.txt项目清单文件的写法
${basedir}/src/main/resources/jar/kingbase8-8.6.0.jar jdbc driver-class-name: com.kingbase8.Driver url: jdbc:kingbase8://127.0.0.1:54321/template1?characterEncoding=utf8 username: system password: ...
For example, if your header file uses the File class in ways that do not require access to the declaration of the File class, your header file can just forward declare class File; instead of having ...