Error: Selection Does Not Contain a Main Type

Error: Selection does not contain a main type

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

screenshot of Eclipse file context menu

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
}

I hope this will help you.

Selection does not contain a main Type - Eclipse Run Error

You dont have a main function defined in the class. The main function is the function that will be called when you run the file.

Try adding

public static void main(String [] args)
{

}

and create and show an object of your JFrame in the main method.

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

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

Java launch error selection does not contain a main type

You cannot define the main method as you do in C++.

For the Java interpreter, the main method must always be public and static. So you need to change your main method signature to

public static void main(String args[])

Try this, and feel free to ask further. :-)

Selection does not contain a main type error when running JavaFX in eclipse.

Add method

public static void main(String[] args) {
launch(args);
}

to your class and run.
You're welcome.

but the FX project is supposed to work without the main method

What exactly do you mean?



Related Topics



Leave a reply



Submit