Aido
Aido

Reputation: 1584

Eclipse: "selection does not contain a main type" error when main function exists

Whenever I try to launch my code, Eclipse gives me the error "selection does not contain a main type" This is my code:

public class main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("Hello World!");

    }

}

Here is the project tree: project tree

for a comment: enter image description here

Upvotes: 1

Views: 3510

Answers (1)

Reimeus
Reimeus

Reputation: 159864

The file is excluded from the run types in Eclipse as it exists outside a source folder. Create a new source folder src/main/java and move the file there.

Here are the basic project source folders for Eclipse:

  • src/main/java - Java source files
  • src/main/resources - Project resources, e.g. images, property files
  • src/test/java - Unit test Java source files
  • src/test/resources - Test resource files

Upvotes: 2

Related Questions