0

I made one simple following class in Eclipse:

package Practice;

public class smallLetterClass {

    public static void main(String[] args){


        smallLetterClass fp=new smallLetterClass();
        fp.flip();

    }

    public void flip(){
        System.out.println("Hi");
    }

}

I got this error:

Error: Main method not found in class Practice.smallLetterClass, please define the main method as:
   public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

Though I was able to resolve it by making Java class name starting with capital letter. Can anyone help in understanding what exactly happened here?

teczarina
  • 72
  • 11
  • how you run this code, it work fine with me – Youcef LAIDANI Jun 02 '17 at 14:35
  • 5
    This ran fine for me too. Though, why are you deliberately naming packages and classes in a way that is not recommended? You should follow [standard naming conventions](https://en.wikipedia.org/wiki/Naming_convention_(programming)#Java). – James_D Jun 02 '17 at 14:42
  • I am using Neon Eclipse with Java 8. I am running it normally as 'Run as Java application' – teczarina Jun 02 '17 at 14:45
  • I did that by mistake, did not intend to! but was wondering on the exception – teczarina Jun 02 '17 at 14:46
  • It runs fine. Something is somehow out of sync: either you haven't saved it, or you have refactored it with the proper naming and are still trying to run it with the old name, or something. So it runs, but you just shouldn't do this at all. The only relationship between the errors you are seeing and the class name is coincidental. – James_D Jun 02 '17 at 15:13
  • @James_D which version of eclipse and java you are using? – teczarina Jun 02 '17 at 15:36
  • It makes no difference. I ran that on jdk1.8.0_121, Eclipse Mars.1 – James_D Jun 02 '17 at 15:38
  • I made multiple versions on Neon, still the same exception. I ran it through MyEclipse(Java 6) it ran successfully, probably I am missing something PS: I even tried making a new project (dynamic web project) in Neon and tried the same code, got the same exception. – teczarina Jun 02 '17 at 16:16

1 Answers1

2

Are you running it as a Java Application? If so, try cleaning the project.

Project > Clean... > OK

If it doesn't help, it means your .metadata folder is corrupted. See this post for resolution.

kagmole
  • 2,005
  • 2
  • 12
  • 27
  • But It ran as soon i refactor it to SmallLetterClass. – teczarina Jun 02 '17 at 14:50
  • Cleaned and tried , got same exception. **Error: Main method not found in class Practice.smallLetterClass, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application** – teczarina Jun 02 '17 at 14:50