“Main method not found” error when starting program? [duplicate]

What you have currently is just a constructor named Main, what Java needs is a main method with exact signature as:

public static void main(String[] args)
  • public – so that it can be called from outside

  • static – so that no need to create an instance of your class

  • void – not going to return any value

  • args – an array for command line parameters that you can specify while running the program

This is the entry point for your application.

When your current code is being invoked, JVM is trying to locate main method, and since its not present in your code, it’s throwing the exception which you have received.

Since you have mentioned beginner in your post, its worth mentioning that Java is a case sensitive languagemain and Main are not same in Java.

See also: The getting started tutorial.

Leave a Comment