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

前端 未结 8 1033
南旧
南旧 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:52

    The problem is that you do not have a public void main(String[] args) method in the class you attempt to invoke.

    It

    • must be static
    • must have exactly one String array argument (which may be named anything)
    • must be spelled m-a-i-n in lowercase.

    Note, that you HAVE actually specified an existing class (otherwise the error would have been different), but that class lacks the main method.

提交回复
热议问题