• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai all,
when i run the program,i got Exception in thread main java.lang.NoSuchMethod Error.
could you please tell me what is the meaning of this.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseAMeaningfulSubjectLine next time.

That means that the class doesn't contain the method. It usually happens when you use the wrong version of a certain library.
Try updating and checking your dependencies.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also please post the Code you are trying to execute.
 
Marshal
Posts: 79152
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked in the API documentation?
 
sakshi sa
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all, i execute the program.

 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be of tremendous help if you posted the exact error you get when you run your code. It makes it easier for dumb people like me to zero in on where the problem is, without having to copy your code, paste it into a document, compile it, and run it (which is what I did).

Once I did that, I saw this error:

Exception in thread "main" java.lang.NoSuchMethodError: main


Seeing that tells me there is a problem with your main method.

Now I know exactly where to look. The main method in this code looks like this:



When you start a java program, it is looking for a main with a signiature of this:



If you simply put in that argument to your main method, the code will run.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the record, here is the code you originally posted, then deleted:

 
Campbell Ritchie
Marshal
Posts: 79152
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not quite sure how Fred found the code you deleted; maybe he was just there in the 5 minutes it was visible. That example shows how bad it can be to delete old posts or parts of them; the remainder of the thread reads like nonsense.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see how comments such as:
// Instance data
// Constructor
// Accessor

help to clarify the code. The fact that it is an instance variable/constructor/getter is made clear by the definition of it. You don't need the comment at all. In fact now you have 2 parts to change if you want to change something. The method definition and the comment. If you forget to change one then voila: confusion.

I can somewhat understand the following comment:
// Implementations of abstract methods.
But Java contains a special annotation for that: @Override. It even has a bonus. If the method doesn't override/implement a method then the compiler will complain.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic