Error: Selection does not contain a main type
I hope you are trying to run the main class in this way, see screenshot:
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 filessrc/main/resources
- Project resources, e.g. images, property filessrc/test/java
- Unit test Java source filessrc/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
How to Add a Filter Class in Spring Boot
Java 8 Lambdas, Function.Identity() or T->T
Why Doesn't Java Support Unsigned Ints
Exception Thrown in Catch and Finally Clause
How to Specify the Default Error Page in Web.Xml
Extract Digits from a String in Java
How to Include Jar Files with Java File and Compile in Command Prompt
Spring MVC @Pathvariable Getting Truncated
How to Open the Default Webbrowser Using Java
Java: Check the Date Format of Current String Is According to Required Format or Not
Natural Sort Order String Comparison in Java - Is One Built In
Convert an Array of Primitive Longs into a List of Longs
Java, Calculate the Number of Days Between Two Dates
Java Wait and Notify: Illegalmonitorstateexception
Setting Background Color for a Jframe