错误处理:could not find the main class, Program will exit
来源:互联网 发布:c语言的运用 编辑:程序博客网 时间:2024/05/16 09:30
原地址:http://blog.csdn.net/xiaogugood/article/details/8284140
1. 先检查环境变量配置是否有错。
a) 打开我的电脑--属性--高级--环境变量
b) 新建系统变量JAVA_HOME和CLASSPATH (注意:网上很多文章让JAVA_HOME为用户环境变量,但是这样做后,在控制台中输入javac,将会提示“javac不是内部或外部命令”)
变量名:JAVA_HOME
变量值:C:\ProgramFiles\Java\jdk1.7.0
变量名:CLASSPATH
变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;(注前面的点号和分号一定不能丢,还有中间的,后面的分号也不要丢了。点号表明将当前工作目录加入到该路径中)
c) 选择“系统变量”中变量名为“Path”的环境变量,双击该变量,把JDK安装路径中bin目录的绝对路径,添加到Path变量的值中,并使用半角的分号和已有的路径进行分隔。
变量名:Path
变量值:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
这是java的环境配置,配置完成后直接启动eclipse,它会自动完成java环境的配置
2. 如果没有错误,那可能是因为我们使用高版本的JDK编译的Javaclass文件试图在较低版本的JVM上运行,所报的错误。因为,高版本的JDK生成的class文件使用的格式,可能与低版本的JDK的.class文件格式不同。这样,低版本的JVM无法解释执行这个.class文件,会抛出Could notfind the main class.program will exit,java.lang.UnsupportedClassVersionE
解决办法:
a) 弄清楚该程序是在哪个JDK版本下开发的(JDK对于java学习者应该不能陌生)
b) Eclipse菜单->Windows->Proferences->java->Installs Jres重新设置JDK路径,改为开发程序时的JDK版本(如上图)(我做到这一步就可以了!我的eclipse是7.0,jdk是6u13的。)
c) Windows->Proferences->java->Compiler,将compiler compliance level设置为与上面相同的JDK(如上图,如果你今天2011年到官方下载的JDK那可能是1.6的了,建议勾选1.6)
参考文章:
1. 《java could not find the mainclass:Welcome. Program will exit问题 》:http://blog.163.com/jackie_howe/blog/static/19949134720111143522313/
2. 《could not find the main class, Programwill exit》:http://www.cnblogs.com/anuoruibo/archive/2012/04/04/2432156.html
3. 百度知道:http://zhidao.baidu.com/question/350104872.html
- 错误处理:could not find the main class, Program will exit
- 错误处理:could not find the main class, Program will exit
- Could not find the main class. Program will exit
- could not find the main class. Program will exit.
- Could not find the main class. Program will exit...
- Could not find the main class. Program will exit
- Could not find the main class.Program will exit.
- Could not find the main class. Program will exit.
- junit:could not find the main class Program will exit
- [Eclipse] Could not find the main class. Program will exit
- could not find the main class : program will exit
- Could not find the main class. Program will exit
- 【解决方法】Could not find the main class Program will exit
- Could not find the main class Program will exit
- Could not find the main class: *****.Program will exit
- Could not find the main class. Program will exit.
- Could not find the main class ***.Program will exit
- Could not find the main class. Program will exit.
- 2017.02.14回顾
- SylixOS_x86_PCI串口驱动浅析
- 冒泡排序和插入排序的一点思考
- websocket api
- elasticsearch-常用查询语法
- 错误处理:could not find the main class, Program will exit
- Java Apache POI组件操作Excel
- ####Service Activity方式
- android动画 通过动画布局声明文件和关联文件为容器布局----布局动画
- Seamless cloning泊松克隆
- Nginx服务器安装
- Trip
- css编码规范(二)
- 微信小程序获取系统日期和时间 —— 微信小程序教程系列(17)