This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Java in General and the fly likes java.lang.NoSuchMethodError Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "java.lang.NoSuchMethodError" Watch "java.lang.NoSuchMethodError" New topic
Author

java.lang.NoSuchMethodError

Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
Hi All..

I have two classes. First class has two static methods. Second class is calling one of the static methods from first class without creating instance.

Both the classes compiled without errors. But while running second class i am getting "java.lang.NoSuchMethodError" where i am calling static method of first class.

Everything seems fine. No compile time error. Then what can be the reason of this runtime error.

Thanks
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3090
    
    5

We need more information:
1) The exact (copy and paste) of the error you get. Likely this will tell you exactly what the problem is
2) The lines of code that cause the error (you can get the location of the error from the stack trace the error give you.



Steve
Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
I can not copy paste exact code but below is the snap shot of it
Classes are as below
swati aole
Greenhorn

Joined: May 02, 2009
Posts: 9
Sona Patel wrote:I can not copy paste exact code but below is the snap shot of it
Classes are as below



I think the java.lang.NoSuchMethodError is thrown because the interpreter is trying to find main() which you'ven't provided..
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3090
    
    5

It could be that there is no public static void main(String[] args) to be executed. Sona, instead of making us guess, could you please copy and paste the error message that you get?
Sona Patel
Ranch Hand

Joined: Mar 30, 2009
Posts: 75
Issue Resolved...
Thank you friends

It was referring to old class file somehow , which did not have newly added method. and hense "NoSuchMethodError"
So i changed the class file with new one and its working now...

thanks for your suggestions...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32833
    
    4
Did you read the API documentation first? That would have been very helpful.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: java.lang.NoSuchMethodError
 
Similar Threads
static and non-static relationship question
Very basic question from a newbie
Using the variable value of one class in another
References between classes
static variables and methods..