File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError

 
Tan Richards
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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));



}

}

}
 
Seb Mathe
Ranch Hand
Posts: 225
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because the main method is in an inner class.
 
Tan Richards
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because class Test6 doesn't have a "main" method; class Test6.tail does. You could run this using

java Test6$tail
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic