“Error: Main method not found in class MyClass, please define the main method as…”

前端 未结 8 1048
南旧
南旧 2020-11-22 01:15

New Java programmers often encounter these messages when they attempt to run a Java program.


Error: Main met         


        
8条回答
  •  逝去的感伤
    2020-11-22 01:46

    Other answers are doing a good job of summarizing the requirements of main. I want to gather references to where those requirements are documented.

    The most authoritative source is the VM spec (second edition cited). As main is not a language feature, it is not considered in the Java Language Specification.

    • 2.17.1 Execution - Virtual Machine Start-up
    • 5.2 Virtual Machine Start-up

    Another good resource is the documentation for the application launcher itself:

    • java - the Java application launcher

提交回复
热议问题