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

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

问题描述

我试图在一个新项目中运行一些java文件。所以我做项目,把文件放在它,我尝试运行主文件,所以我的游戏开始。



我收到一条错误,说选择不包含主要类型



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




  • 有人说再次启动eclipse,尝试了十几次。

  • 某处还有人指出要打开一个新项目,并为旧项目建立路径。



没有工作。



我很确定它必须工作,因为我几个小时前在学校跑了。我该如何让这个工作?先谢谢你!

解决方案

希望以这种方式运行主类,看屏幕截图:



如果没有,那么尝试这种方式,如果是的话请确保您要运行的课程有主要方法,例如

  public static void main(String [] args){ //这里的一些代码

同样的定义。希望这将有助于您。


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.

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

I have tried several ways to run it:

  • Some say to launch eclipse again, tried this a dozen times.
  • Somewhere else someone pointed to open a new project and make a build path to the old project.

Didn't work either.

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!

解决方案

Hope you are trying to run the main class in this way see screen shot:

If no then try this way and if yes then please make sure that your class you are going to run have main method i-e

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

same definition. Hope this will help you.

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

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