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 Message 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 Message" Watch "Error Message" New topic
Author

Error Message

Shae Weathers
Greenhorn

Joined: Jun 26, 2010
Posts: 8
Whenever I try to run my program, I keep getting the same message : Exception in thread "main" java.lang.NoSuchMethodError: main
What does this mean or what am I doing wrong?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Hi,

Every Java application nominally needs a method named "main" that takes an array of Strings as its single argument, is declared public static, and returns void:



This is the method the JVM calls when the application starts up. When you start your program with "java ClassName", the class ClassName has to be the one that contains your method "main()".

Does that help?


[Jess in Action][AskingGoodQuestions]
Shae Weathers
Greenhorn

Joined: Jun 26, 2010
Posts: 8
I totally had a memory lapse..I was working on an applet and was trying to run it in the command prompt. I finally realized what I was doing wrong.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
For applets you usually use the appletviewer instruction, or something like that, at the command line, don't you?
Enrique Gonzalez Moore
Greenhorn

Joined: Jun 12, 2010
Posts: 7
You should create an html document with an applet tag. Something similar to this:



 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error Message
 
Similar Threads
Joining Thread, Explanation required
Error
how to override width and height params in applet tag
Many Problems Compiling HelloWorld.java
Message driven bean