This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

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?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

And next time, UseOneThreadPerQuestion. We'll continue here.
 
 
subject: noSuchMethod exception
 
Similar Threads
No main-method
conflict due class is having same name as well as same package structure
Class loading hierrarchy
Chapter 10 K&B
What will be the name of .java file?