File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "NoSuchMethodError" Watch "NoSuchMethodError" New topic


Tan Richards

Joined: Sep 29, 2005
Posts: 18
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[])






"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

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

Joined: Jul 08, 2003
Posts: 24199

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:
subject: NoSuchMethodError
It's not a secret anymore!