Re: "Exception in thread "main" java.lang.nosuchmethodError: main"
- From: Peter MacMillan <peter@xxxxxxxxxxxxx>
- Date: Wed, 27 Apr 2005 11:38:21 -0400
keith vescovo via JavaKB.com wrote:
I keep getting this message when trying to run a java program that calculates the hypotenuse of a right triangle. The program will compile, but it won't run. Could someone please help me with this? Any help will be greatly appreciated. Here is the code for my program:
[subject="Exception in thread "main" java.lang.nosuchmethodError: main"]
That error means that the class doesn't have a static method with the signature "void main(String[])".
But I notice that your class is an Applet. Ah! Create the following html file and save it in the same directory as your class:
//--- Triangle.html (do not include this line) <html> <head></head> <body> <applet code="Triangle.class" width="300" height="100"></applet> </body> </html> //--- (do not include this line)
And then, from the console, run: appletviewer Triangle.html
or load the html file in your web browser (make sure the .class file is in the same directory).
If you want to run the class with the java command, you must create a public static method called main:
//---
public static void main(String[] args) { ... }
//---
-- Peter MacMillan e-mail/msn: peter@xxxxxxxxxxxxx .
- Follow-Ups:
- Re: "Exception in thread "main" java.lang.nosuchmethodError: main"
- From: keith vescovo via JavaKB.com
- Re: "Exception in thread "main" java.lang.nosuchmethodError: main"
- References:
- "Exception in thread "main" java.lang.nosuchmethodError: main"
- From: keith vescovo via JavaKB.com
- "Exception in thread "main" java.lang.nosuchmethodError: main"
- Prev by Date: Java threads and WinLogon processes take CPU!
- Next by Date: Re: Saving and Opening an Array List
- Previous by thread: "Exception in thread "main" java.lang.nosuchmethodError: main"
- Next by thread: Re: "Exception in thread "main" java.lang.nosuchmethodError: main"
- Index(es):
Relevant Pages
|