aspose file tools*
The moose likes Java in General and the fly likes NoSuchMethodError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoSuchMethodError" Watch "NoSuchMethodError" New topic
Author

NoSuchMethodError

Tan Richards
Greenhorn

Joined: Sep 29, 2005
Posts: 18
Hi,
Can anybody tell me why I'm getting NoSuchMethodError while trying to execute the following code?

class one{

static int giveMe(boolean b) {

try {
if (b) {

return 1;

}

return 0;

}

finally {

System.out.println("Inside finally");

}

}

}



public class Test6{

static class tail{

public static void main(String args[])

{

System.out.println(one.giveMe(true));



}

}

}


"Failures are pillars of success" - That doesn't mean you go on building pillars
Seb Mathe
Ranch Hand

Joined: Sep 28, 2005
Posts: 225
That's because the main method is in an inner class.


Regards,<br />Seb<br /> <br />SCJP 1.4
Tan Richards
Greenhorn

Joined: Sep 29, 2005
Posts: 18
Hi Seb,
Thanx for the explanation. But actually I wanted to know why it is happening like this when the main method is inside an inner class.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Because class Test6 doesn't have a "main" method; class Test6.tail does. You could run this using

java Test6$tail


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoSuchMethodError