NoSuchMethodError

NoSuchMethodError


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.

NoSuchMethodError

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 Reply

Your email address will not be published. Required fields are marked *