File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes noSuchMethod exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

noSuchMethod exception

Mahesh Bamane
Ranch Hand

Joined: Mar 12, 2008
Posts: 68
Well, I've been dealing with a big problem. I have two classes which has same class name and package structure they are present in two different jars for sure.
When I call a method of one class say for example setName.
I get an exception saying noSuchMethod; what can be the possible soluntion in this regard.
As classes are in jars I cant make any changes to them.

There is nothing like trying, either you do it or you don't.
SCJP 1.5
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

As long those jars are not signed (and in some cases even if they are) you can rename jar file to zip and do all the changes you want.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

You don't even need to rename them; JAR files can be opened with all ZIP applications just fine.

But two versions of a class seems like a bad design. Is this a class written by yourself or a colleague, or did you get the JAR files from the Internet?

How To Ask Questions How To Answer Questions
Rob Spoor

Joined: Oct 27, 2005
Posts: 20275

And next time, UseOneThreadPerQuestion. We'll continue here.
I agree. Here's the link:
subject: noSuchMethod exception
jQuery in Action, 3rd edition