错误:选择不包含主要类型 [英] Error: Selection does not contain a main type

查看:50
本文介绍了错误:选择不包含主要类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新项目中运行一些 java 文件.所以我制作了这个项目,把文件放进去,然后我尝试运行主文件,这样我的游戏就开始了.

I am trying to run some java files in a new project. So I make the project, put the files in it and I try to run the main file so my game starts.

我收到一条错误消息,指出 selection 不包含主要类型.

I get an error that says selection does not contain a main type.

我尝试了几种方法来运行它:

I have tried several ways to run it:

  • 有人说要再次启动 eclipse,试了十几次.
  • 有人指出在其他地方打开一个新项目并为旧项目创建一个构建路径.

也没有用.

我很确定它一定能用,因为我几个小时前在学校运行过它.我如何让这个工作?先感谢您!

I am pretty sure it must work because I ran it a few hours ago at school. How do I get this working? Thank you in advance!

推荐答案

希望你尝试用这种方式运行主类,看截图:

I hope you are trying to run the main class in this way, see screenshot:

如果没有,那么试试这个方法.如果是,那么请确保您尝试运行的类有一个 main 方法,即与下面相同的方法定义:

If not, then try this way. If yes, then please make sure that your class you are trying to run has a main method, that is, the same method definition as below:

public static void main(String[] args) {
    // some code here
}

希望对你有所帮助.

这篇关于错误:选择不包含主要类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆