Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Selection does not contain a main type

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!

like image 742
user2321611 Avatar asked Apr 25 '13 21:04

user2321611


People also ask

What is the error editor does not contain a main type?

Basically, this type of Error means your Editor is not able to find the “main” method in any of your current program classes. The editor shows this error because when you want to run the project, at that time, the interpreter couldn't find the main function to start the execution of the program.

What is main type?

MainType is a powerful but easy to use font manager and font viewer for Windows, that takes the frustration out of managing your fonts. It is packed with tons of intuitive features that makes it simple to find, preview, organize, install, and print your fonts.

What is the main type in java?

public static void main(String[] args) Java main method is the entry point of any java program. Its syntax is always public static void main(String[] args) .


1 Answers

Right click on the folder where you put your main class then click on Build Path --> Use as Source Folder.

Finally run your main file as java application. Hope this problem will be solved.

If the option 'Use as Source Folder' is not visible then inside the 'Build Path' select the option 'Remove from Build Path'. This will allow 'Use as Source Folder' option to appear in the 'Build Path'.

like image 199
Rashid Avatar answered Oct 13 '22 00:10

Rashid