1

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

Aido
  • 1,524
  • 3
  • 18
  • 41
  • possible duplicate of [Error: Selection does not contain a main type](http://stackoverflow.com/questions/16225177/error-selection-does-not-contain-a-main-type) – jww Sep 30 '14 at 05:46

1 Answers1

1

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
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • Should the images go in src as well? – Aido Jun 24 '13 at 03:16
  • Place images in `src/main/resources`. They can be loaded using `Class#getResource` later. – Reimeus Jun 24 '13 at 03:18
  • Sorry I'm new with eclipse, but what kind of folders should they be? I understand that there are regular and source folders, but I don't know the diffrence – Aido Jun 24 '13 at 03:19
  • Consider a source folder as a search location to look for resources for a project. Conversely regular folders are not search locations – Reimeus Jun 24 '13 at 03:27
  • So I do make them source folders? – Aido Jun 24 '13 at 03:32
  • You mean the folders `Maps` and `Images`? Move them both to `src/main/resources`. Those folders will be copied to the class ouput directory when the project is built. – Reimeus Jun 24 '13 at 03:41
  • ummm... is this supposed to happen?(see main post) – Aido Jun 24 '13 at 03:48