"Error: Main method not found in class MyClass, bitte definieren Sie die main-Methode als..."

Neuen Java-Programmierer oft auf diese Meldungen, wenn Sie versuchen, führen Sie ein Java-Programm.


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

Error: Main method is not static in class MyClass, please define the main method as:
   public static void main(String[] args)

Error: Main method must return a value of type void in class MyClass, please
define the main method as:
   public static void main(String[] args)

java.lang.NoSuchMethodError: main
Exception in thread "main"

Was bedeutet das, was es bewirken kann, und was sollte man tun, um es zu beheben?

  • Nur raten Sie eine Funktion aufrufen, die nicht existiert, aber der compiler soll Sie stoppen, wenn Sie tun.
  • Wikification abgeschlossen.
  • Dies ist ein Fall, dass der compiler nicht umgehen können. Siehe meine Antwort für details.
Schreibe einen Kommentar