Shaul Behr
Shaul Behr

Reputation: 38091

java.lang.NoSuchMethodError, with both classes in the same JAR!

My Java skills are a little rusty, but this is really weird: I am getting a java.lang.NoSuchMethodError at runtime when calling a method in a different class - note that the code compiled fine - and the other class is contained in the same JAR as the calling method!

That would seem to indicate it's not a classpath issue - but then what?

Upvotes: 7

Views: 3132

Answers (2)

Ajay Takur
Ajay Takur

Reputation: 6236

when calling a method from one class to other class make sure that calling method name and called method name should be same and then recompile again the classes that you made changes of both method names

Upvotes: 0

DaveC
DaveC

Reputation: 2050

Check out this article. http://snippets.dzone.com/posts/show/3719

URL myClassURL = MyMysteryClass.class.getProtectionDomain().getCodeSource().getLocation();

That will tell you exactly where your class is being loaded from (according to the article). Should clear up any classpath questions.

Upvotes: 10

Related Questions