I can\'t find exact difference between NoSuchMethodException
and NoSuchMethodError
in Java. Could someone give explanation and example of these two th
NoSuchMethodException
is thrown when you try and get a method that doesn't exist with reflection. E.g. by calling Class#getDeclaredMethod(name, parameters)
with either the wrong name or parameters.
NoSuchMethodError
is thrown when the virtual machine cannot find the method you are trying to call. This can happen when you compile with one version of a library, and later run the application with another version of the library on the classpath (e.g. an older one that doesn't have the method you're calling)