This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error" Watch "Error" New topic
Author

Error

sakshi sa
Greenhorn

Joined: Jan 18, 2011
Posts: 7
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.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Also please post the Code you are trying to execute.


Mohamed Sanaulla | My Blog
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Have you looked in the API documentation?
sakshi sa
Greenhorn

Joined: Jan 18, 2011
Posts: 7
Thanks to all, i execute the program.

fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

For the record, here is the code you originally posted, then deleted:

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
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
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

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.
 
subject: Error
 
Similar Threads
Tomcat & MS Active Directory
Encapsulation and getter&setter methods
i have a Errors in Hibernate Query
ServletContext
File not found error