editor does not contain a main type的解决方案

今天用eclipse,当打算run一个带有main函数的class时,出现editor does not contain a main type的错误框。

baidu了一下,迅速解决问题:原来这个class所在包没有被添加到build path中。

解决方法:在左侧的package explorer中右击这个class所在包的上一级目录--build path--use as source folder。这样就解决问题了。

重新打开class,再run一下,ok了。

-----------------------------------------------------
补充和解释:

哎,好吧。再稍微简单解释下。

看这张图,src就是在build path中的(仔细观察src的图标) 
相对的,resource就只是个普通文件夹,而不在build path中(图标和src不一样吧?) 
然后我又在resource下新建了文件夹和文件,比较下,包和文件夹的图标也是不一样的。

现在,我要把resource也加到build path中。(方法就是右击resource--build path--use as source folder)

这样,src和resource就都在build path中了。

最后,解释下,什么叫“在build path中”?你可以这么理解,eclipse中,在build path下的类可以被编译运行,在build path下的配置文件可以被类以相对路径直接读写。

editor does not contain a main type的解决方案的更多相关文章

  1. Eclipse 软件 Java 解决:出现的editor does not contain a main type错误框 问题

    Eclipse 软件 解决:出现的 editor does not contain a main type 错误框 问题 当你运行 Java文件是,如果弹出了下面的 错误框: 出现错误的原因: 当前的 ...

  2. MyEclipse上有main函数类运行报错:Editor does not contain a main type

    MyEclipse下有main函数类运行报错:Editor does not contain a main type 出现这种问题的原因是,该java文件所在的包没有被MyEclipse认定为源码包. ...

  3. eclipse解决editor does not contain a main type的方法

    转自:http://blog.csdn.net/huazhangena/article/details/7349044 写在前面的话:我的也出现这个问题,但是解决方法和转发的内容不太一样,原理一样,我 ...

  4. 【eclipse】Editor does not contain a main type

    问题现象: eclipse运行java程序的时候弹出对话框:Editor does not contain a main type. 解决方法: 右击 src路径 → Build Path → Use ...

  5. editor does not cantain a main type——解决

    editor does not cantain a main type 这个错误就是包名与路径不对

  6. Editor does not contain a main type

    1.错误描述 2.错误原因 在含有main方法的类中,运行应用程序,却提示这个错误:编译器不包含main类型 3.解决办法 (1)选择该Java类上一级文件,build path--->use ...

  7. “selection does not contain a main type”解决方法

    在运行java程序时,出现了错误“selection does not contain a main type”. 是因为.java文件不在项目的src路径内,也就是说源代码未被eclipse编译,字 ...

  8. WPF学习- 新建项目后自定义Main()[Type 'App' already defines a member called 'Main' with the same parameter types]

    问题点: 在App.xaml.cs中自己添加Main方法,编译会出现如下报错: 错误 CS0111 类型“App”已定义了一个名为“Main”的具有相同参数类型的成员  错误 Type 'App' a ...

  9. mybatis-plus的Could not set property 'updateDate' of 'class com.example.pojo.User' with value 'Fri Jul 24 10:29:39 CST 2020' Cause: java.lang.IllegalArgumentException: argument type mismatch解决方案

    按照官网在写mybatis-plus的自动填充功能一直报错,发现官网的解说不全,数据库是datetime类型,java程序又是date,类型不匹配 org.mybatis.spring.MyBatis ...

随机推荐

  1. deepin linux字体渲染(转)

    <?xml version='1.0'?> <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> <fontconfig> <ma ...

  2. ie浏览器兼容问题汇总

    对兼容ie浏览器所遇到的问题及总结 互联快谈 2016-10-28 05:51 1,若直接给一个元素设置absolute定位.在浏览器缩放的时候.位置会错位.解决的方法是给外层的元素设置为relati ...

  3. UIImage

    //设置UIImage的圆角 + (UIImage *)imageNamed:(NSString *)name size:(CGSize)size cornerRadius:(CGFloat)corn ...

  4. Ubuntu 下 kazam 录屏 没声音解决方案

    以下内容参考https://www.youtube.com/watch?v=5NZ0qwp2L04,我做了些修改,让它好懂些. 在应用商店里搜索 PulseAudio Volume Control 在 ...

  5. windows系统查看被占用的端口号

    我们需要查看80端口被哪个进程占用了, 1. netstat -ano|findstr 80

  6. Java 找不到主类错误

    Eclipse 运行java 程序,突然出现错误:没有或找不到主类. 在网上找了好多办法,都不行. jdk环境配置啊-->这个一般不会出错,因为以前都不会出现这种问题. 查看项目配置啥的--&g ...

  7. Android Build System

    归类一些Android build system 相关的知识. http://elinux.org/Android_Build_System make <local_module> - m ...

  8. Python的入门要点

    一.输入 1.键盘输入 在python 2.7中,不用input(),而用 raw_input()读入一行键盘输入,并转化为字符串. s = map(int ,raw_input().split()) ...

  9. java中equals和“==”补充

    在JDK1.5之后,Integer添加了自动装箱,其形式为Integer i = 5; 装箱过程在内存中是  i = new Integer(4);大家都很熟悉这个吧. 当使用这中形式的时候,equa ...

  10. Access restriction: The type TaskTopicResolver is not accessible due to restrict

    Access restriction: The type TaskTopicResolver is not accessible due to restrict :  Eclipse 默认把这些受访问 ...