It is a checked exception, generally we experience, when we try to execute a class without main() method. Following is the hierarchy of NoSuchMethodError.

Object –> Throwable –> Error –> LinkageError –> IncompatibleClassChangeError –> NoSuchMethodError

Full hierarchy of exceptions is available at "Hierarchy of Exceptions – Checked/Unchecked Exceptions".

Following program illustrates.

public class Demo



The above code compiles normally (because Java does not require main() to compile) but does not execute and throws NoSuchMethodError. See the screenshot. JVM means, it is an error as no such method like main() is available to execute the program.

Leave a Comment

Your email address will not be published.