今天在Eclipse上新建了一个项目,编写并运行程序的时候弹出一个“Launch Error”错误对话框,曰:selection does not contain a main type。再编写一个简单的HelloWorld程序测试,发现结果一样。
上网查找原因,找到一个解决办法:
出现这个问题,是因为java文件不在项目的src路径内,也就是说源代码未被eclipse编译,字节码不存在无法运行了。在项目名上右键 -> Builder Path -> Configure Build Path -> 选择Source面板,再点Add Folder, 把源代码所在的包路径的上层目录加进来.
操作起来挺麻烦的,弄了好一会也没弄好,干脆自己找解决办法好了。
我再次新建一个项目,编写程序并运行,发现没有该错误,奇怪了。
仔细想想两个项目的不同之处,不同的地方就是在新建项目的时候第一个项目勾选了Java Settings下的Allow output folders for source folders,而第二个项目则没有勾选,莫非问题就出现在这里?
重新再新建已项目,勾选Allow output folders for source folders选项,编写程序运行,果然再次发现selection does not contain a main type错误。
问题解决。
分享到:
相关推荐
如果一个Java项目中的编辑器提示“does not contain a main type”或“selection does not contain a main type”,这通常意味着当前选中的文件或类没有包含正确的`main`方法。 #### 解决方法 1. **检查Main方法**...
(b) The type of relationship that does not belong anywhere (c) The type of relationship between entities of one entity type (d) A never-ending type of relationship Correct answer is (c) 2. In...
type can now be defined as a sequence: TEnum = ( eOne, eTwo ); . . . EnumProp.SetItem(integer(eOne), 'One'); EnumProp.SetItem(integer(eTwo), 'Two'); If some items are skipped when filling data ...
- pro and premium: Due to a problem with precompiler cursoir selection did not work correctly 8.3.2012 - WPTools 6.25.3' - borders for paragraphs with multiple lines were not drawn correctly - ...
(*) Windows 2000 does not support the CD-RW burn test. The advanced RAM test is only available under Windows 2000 and Windows XP professional (the other RAM tests are supported under the other OS's)...
The leaf level of a clustered index contains the data pages, not just the index keys. Another way to say this is that the data itself is part of the clustered index. A clustered index keeps the data ...
(A)启动Excel,选择菜单“数据->导入外部数据->导入数据”,选择RadminM.txt文件; (B)文本导入向导第1步,直接单击“下一步”; (C)第2步必须选中“逗号”分隔符,再单击“下一步”; (D)第3步必须将所有18列都...
(A)启动Excel,选择菜单“数据->导入外部数据->导入数据”,选择RadminM.txt文件; (B)文本导入向导第1步,直接单击“下一步”; (C)第2步必须选中“逗号”分隔符,再单击“下一步”; (D)第3步必须将所有18列都...